1{stdenv, fetchFromGitHub, bash, which, m4, python, bison, flex, llvmPackages, clangWrapSelf,
2testedTargets ? ["sse2" "host"] # the default test target is sse4, but that is not supported by all Hydra agents
3}:
4
5# TODO: patch LLVM so Skylake-EX works better (patch included in ispc github) - needed for LLVM 3.9?
6
7stdenv.mkDerivation rec {
8 version = "1.9.1";
9 rev = "v${version}";
10
11 inherit testedTargets;
12
13 name = "ispc-${version}";
14
15 src = fetchFromGitHub {
16 owner = "ispc";
17 repo = "ispc";
18 inherit rev;
19 sha256 = "1wwsyvn44hd5iyi5779l5378x096307slpyl29wrsmfp66796693";
20 };
21
22 # there are missing dependencies in the Makefile, causing sporadic build failures
23 enableParallelBuilding = false;
24
25 doCheck = true;
26
27 buildInputs = with llvmPackages; [
28 which
29 m4
30 python
31 bison
32 flex
33 llvm
34 llvmPackages.clang-unwrapped # we need to link against libclang, so we need the unwrapped
35 ];
36
37 postPatch = "sed -i -e 's/\\/bin\\///g' -e 's/-lcurses/-lncurses/g' Makefile";
38
39 # TODO: this correctly catches errors early, but also some things that are just weird and don't seem to be real
40 # errors
41 #configurePhase = ''
42 # makeFlagsArray=( SHELL="${bash}/bin/bash -o pipefail" )
43 #'';
44
45 installPhase = ''
46 mkdir -p $out/bin
47 cp ispc $out/bin
48 '';
49
50 checkPhase = ''
51 export ISPC_HOME=$PWD
52 for target in $testedTargets
53 do
54 echo "Testing target $target"
55 echo "================================"
56 echo
57 PATH=${llvmPackages.clang}/bin:$PATH python run_tests.py -t $target --non-interactive --verbose --file=test_output.log
58 fgrep -q "No new fails" test_output.log || exit 1
59 done
60 '';
61
62 makeFlags = [
63 "CXX=${llvmPackages.clang}/bin/clang++"
64 "CLANG=${llvmPackages.clang}/bin/clang"
65 "CLANG_INCLUDE=${llvmPackages.clang-unwrapped}/include"
66 ];
67
68 meta = with stdenv.lib; {
69 homepage = https://ispc.github.io/ ;
70 description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
71 license = licenses.bsd3;
72 platforms = ["x86_64-linux"]; # TODO: buildable on more platforms?
73 maintainers = [ maintainers.aristid ];
74 };
75}