2021-04-08 16:26:57 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
2020-04-24 23:36:52 +00:00
|
|
|
, cmake, which, m4, python3, bison, flex, llvmPackages
|
|
|
|
|
|
|
|
# the default test target is sse4, but that is not supported by all Hydra agents
|
|
|
|
, testedTargets ? [ "sse2" ]
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "ispc";
|
2021-04-08 16:26:57 +00:00
|
|
|
version = "unstable-2021-04-02";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2021-04-08 16:26:57 +00:00
|
|
|
# ISPC release 1.15.0 doesn't build against LLVM 11.1, only against 11.0. So we
|
|
|
|
# use latest ISPC main branch for now, until they support an LLVM version we have.
|
|
|
|
# https://github.com/ispc/ispc/issues/2027#issuecomment-784470530
|
|
|
|
rev = "3e8313568265d2adfbf95bd6b6e1a4c70ef59bed";
|
|
|
|
sha256 = "sha256-gvr+VpoacmwQlP5gT4MnfmKdACZWJduVMIpR0YRzseg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-04-08 16:26:57 +00:00
|
|
|
patches = [
|
|
|
|
# Fix cmake error: `Failed to find clang++`
|
|
|
|
# https://github.com/ispc/ispc/pull/2055
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/erictapen/ispc/commit/338119b2f4e11fcf0b0852de296c320928e572a2.patch";
|
|
|
|
sha256 = "sha256-+RqDq1LMWomu/K4SgK0Nip47b1RwyM6W0cTSNGD4+m4=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake which m4 bison flex python3 ];
|
|
|
|
buildInputs = with llvmPackages; [
|
|
|
|
# we need to link against libclang, so we need the unwrapped
|
|
|
|
llvm llvmPackages.clang-unwrapped
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace curses ncurses
|
|
|
|
substituteInPlace cmake/GenerateBuiltins.cmake \
|
|
|
|
--replace 'bit 32 64' 'bit 64'
|
|
|
|
'';
|
|
|
|
|
|
|
|
inherit testedTargets;
|
|
|
|
|
|
|
|
# needs 'transcendentals' executable, which is only on linux
|
|
|
|
doCheck = stdenv.isLinux;
|
|
|
|
|
|
|
|
# the compiler enforces -Werror, and -fno-strict-overflow makes it mad.
|
|
|
|
# hilariously this is something of a double negative: 'disable' the
|
|
|
|
# 'strictoverflow' hardening protection actually means we *allow* the compiler
|
|
|
|
# to do strict overflow optimization. somewhat misleading...
|
|
|
|
hardeningDisable = [ "strictoverflow" ];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
export ISPC_HOME=$PWD/bin
|
|
|
|
for target in $testedTargets
|
|
|
|
do
|
|
|
|
echo "Testing target $target"
|
|
|
|
echo "================================"
|
|
|
|
echo
|
|
|
|
(cd ../
|
|
|
|
PATH=${llvmPackages.clang}/bin:$PATH python run_tests.py -t $target --non-interactive --verbose --file=test_output.log
|
|
|
|
fgrep -q "No new fails" test_output.log || exit 1)
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCLANG_EXECUTABLE=${llvmPackages.clang}/bin/clang"
|
2021-04-08 16:26:57 +00:00
|
|
|
"-DCLANGPP_EXECUTABLE=${llvmPackages.clang}/bin/clang++"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DISPC_INCLUDE_EXAMPLES=OFF"
|
|
|
|
"-DISPC_INCLUDE_UTILS=OFF"
|
|
|
|
"-DARM_ENABLED=FALSE"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://ispc.github.io/";
|
|
|
|
description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ]; # TODO: buildable on more platforms?
|
|
|
|
maintainers = with maintainers; [ aristid thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|