1 { lib, stdenv, fetchFromGitHub, fetchpatch
2 , cmake, which, m4, python3, bison, flex, llvmPackages, ncurses, xcode, tbb
3 # the default test target is sse4, but that is not supported by all Hydra agents
4 , testedTargets ? if stdenv.isAarch64 || stdenv.isAarch32 then [ "neon-i32x4" ] else [ "sse2-i32x4" ]
7 stdenv.mkDerivation rec {
11 src = fetchFromGitHub {
15 sha256 = "sha256-NiBwQ7BzNgRdWLvjOi1fQni+vnYwn0nLHxqAVucmb2k=";
18 nativeBuildInputs = [ cmake which m4 bison flex python3 llvmPackages.libllvm.dev tbb ] ++ lib.lists.optionals stdenv.isDarwin [ xcode ];
20 buildInputs = with llvmPackages; [
21 libllvm libclang openmp ncurses
25 substituteInPlace CMakeLists.txt \
26 --replace CURSES_CURSES_LIBRARY CURSES_NCURSES_LIBRARY
27 substituteInPlace cmake/GenerateBuiltins.cmake \
28 --replace 'bit 32 64' 'bit 64'
31 inherit testedTargets;
35 # the compiler enforces -Werror, and -fno-strict-overflow makes it mad.
36 # hilariously this is something of a double negative: 'disable' the
37 # 'strictoverflow' hardening protection actually means we *allow* the compiler
38 # to do strict overflow optimization. somewhat misleading...
39 hardeningDisable = [ "strictoverflow" ];
42 export ISPC_HOME=$PWD/bin
43 for target in $testedTargets
45 echo "Testing target $target"
46 echo "================================"
49 PATH=${llvmPackages.clang}/bin:$PATH python run_tests.py -t $target --non-interactive --verbose --file=test_output.log
50 fgrep -q "No new fails" test_output.log || exit 1)
55 "-DFILE_CHECK_EXECUTABLE=${llvmPackages.llvm}/bin/FileCheck"
56 "-DLLVM_AS_EXECUTABLE=${llvmPackages.llvm}/bin/llvm-as"
57 "-DLLVM_CONFIG_EXECUTABLE=${llvmPackages.llvm.dev}/bin/llvm-config"
58 "-DLLVM_DIS_EXECUTABLE=${llvmPackages.llvm}/bin/llvm-dis"
59 "-DCLANG_EXECUTABLE=${llvmPackages.clang}/bin/clang"
60 "-DCLANGPP_EXECUTABLE=${llvmPackages.clang}/bin/clang++"
61 "-DISPC_INCLUDE_EXAMPLES=OFF"
62 "-DISPC_INCLUDE_UTILS=OFF"
63 ("-DARM_ENABLED=" + (if stdenv.isAarch64 || stdenv.isAarch32 then "TRUE" else "FALSE"))
64 ("-DX86_ENABLED=" + (if stdenv.isx86_64 || stdenv.isx86_32 then "TRUE" else "FALSE"))
65 ] ++ lib.lists.optionals stdenv.isDarwin [
66 "-DISPC_MACOS_SDK_PATH=${xcode}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
70 homepage = "https://ispc.github.io/";
71 description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
72 license = licenses.bsd3;
73 platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; # TODO: buildable on more platforms?
74 maintainers = with maintainers; [ aristid thoughtpolice athas alexfmpe ];