nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 which,
7 m4,
8 python3,
9 bison,
10 flex,
11 llvmPackages,
12 ncurses,
13 onetbb,
14 # the default test target is sse4, but that is not supported by all Hydra agents
15 testedTargets ?
16 if stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isAarch32 then
17 [ "neon-i32x4" ]
18 else
19 [ "sse2-i32x4" ],
20}:
21
22stdenv.mkDerivation (finalAttrs: {
23 pname = "ispc";
24 version = "1.29.1";
25
26 src = fetchFromGitHub {
27 owner = "ispc";
28 repo = "ispc";
29 tag = "v${finalAttrs.version}";
30 hash = "sha256-4kYyUBGhTS9XurRjxXnEv12+UzZvSnu7DndhS5AhwQo=";
31 };
32
33 nativeBuildInputs = [
34 cmake
35 which
36 m4
37 bison
38 flex
39 python3
40 llvmPackages.libllvm.dev
41 onetbb
42 ];
43
44 buildInputs = with llvmPackages; [
45 libllvm
46 libclang
47 openmp
48 ncurses
49 ];
50
51 postPatch =
52 # Workaround for LLVM version mismatch: the build uses libcxx 19 (from darwin
53 # stdenv), while LLVM 21 is provided as a runtime dependency.
54 lib.optionalString stdenv.hostPlatform.isDarwin ''
55 substituteInPlace src/util.cpp \
56 --replace-fail "#ifdef _LIBCPP_VERSION" "#if FALSE"
57 '';
58
59 inherit testedTargets;
60
61 doCheck = true;
62
63 # the compiler enforces -Werror, and -fno-strict-overflow makes it mad.
64 # hilariously this is something of a double negative: 'disable' the
65 # 'strictoverflow' hardening protection actually means we *allow* the compiler
66 # to do strict overflow optimization. somewhat misleading...
67 hardeningDisable = [ "strictoverflow" ];
68
69 checkPhase = ''
70 export ISPC_HOME=$PWD/bin
71 for target in $testedTargets
72 do
73 echo "Testing target $target"
74 echo "================================"
75 echo
76 (cd ../
77 PATH=${llvmPackages.clang}/bin:$PATH python scripts/run_tests.py -t $target --non-interactive --verbose --file=test_output.log
78 fgrep -q "No new fails" test_output.log || exit 1)
79 done
80 '';
81
82 cmakeFlags = [
83 (lib.cmakeFeature "FILE_CHECK_EXECUTABLE" "${llvmPackages.llvm}/bin/FileCheck")
84 (lib.cmakeFeature "LLVM_AS_EXECUTABLE" "${llvmPackages.llvm}/bin/llvm-as")
85 (lib.cmakeFeature "LLVM_CONFIG_EXECUTABLE" "${llvmPackages.llvm.dev}/bin/llvm-config")
86 (lib.cmakeFeature "CLANG_EXECUTABLE" "${llvmPackages.clang}/bin/clang")
87 (lib.cmakeFeature "CLANGPP_EXECUTABLE" "${llvmPackages.clang}/bin/clang++")
88 (lib.cmakeBool "ISPC_INCLUDE_EXAMPLES" false)
89 (lib.cmakeBool "ISPC_INCLUDE_UTILS" false)
90 (lib.cmakeFeature "ARM_ENABLED=" (
91 if stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isAarch32 then "TRUE" else "FALSE"
92 ))
93 (lib.cmakeFeature "X86_ENABLED=" (
94 if stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isx86_32 then "TRUE" else "FALSE"
95 ))
96 ];
97
98 meta = {
99 description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
100 homepage = "https://ispc.github.io/";
101 changelog = "https://github.com/ispc/ispc/releases/tag/v${finalAttrs.version}";
102 license = lib.licenses.bsd3;
103 maintainers = with lib.maintainers; [
104 thoughtpolice
105 athas
106 alexfmpe
107 ];
108 mainProgram = "ispc";
109 platforms = with lib.platforms; linux ++ darwin; # TODO: buildable on more platforms?
110 };
111})