2021-04-08 16:26:57 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
2022-06-16 17:23:12 +00:00
|
|
|
, cmake, which, m4, python3, bison, flex, llvmPackages, ncurses
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# the default test target is sse4, but that is not supported by all Hydra agents
|
2023-01-11 07:51:40 +00:00
|
|
|
, testedTargets ? if stdenv.isAarch64 || stdenv.isAarch32 then [ "neon-i32x4" ] else [ "sse2-i32x4" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "ispc";
|
2022-12-17 10:02:37 +00:00
|
|
|
version = "1.18.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2022-06-16 17:23:12 +00:00
|
|
|
rev = "v${version}";
|
2022-12-17 10:02:37 +00:00
|
|
|
sha256 = "sha256-WBAVgjQjW4x9JGx6xotPoTVOePsPjBJEyBYA7TCTBvc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ cmake which m4 bison flex python3 llvmPackages.libllvm.dev ];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = with llvmPackages; [
|
2022-06-16 17:23:12 +00:00
|
|
|
libllvm libclang openmp ncurses
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace CMakeLists.txt \
|
2022-06-16 17:23:12 +00:00
|
|
|
--replace CURSES_CURSES_LIBRARY CURSES_NCURSES_LIBRARY
|
2020-04-24 23:36:52 +00:00
|
|
|
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 = [
|
2021-05-20 23:08:51 +00:00
|
|
|
"-DLLVM_CONFIG_EXECUTABLE=${llvmPackages.llvm.dev}/bin/llvm-config"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-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"
|
2023-01-11 07:51:40 +00:00
|
|
|
("-DARM_ENABLED=" + (if stdenv.isAarch64 || stdenv.isAarch32 then "TRUE" else "FALSE"))
|
|
|
|
("-DX86_ENABLED=" + (if stdenv.isx86_64 || stdenv.isx86_32 then "TRUE" else "FALSE"))
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
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;
|
2023-01-11 07:51:40 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; # TODO: buildable on more platforms?
|
2022-06-16 17:23:12 +00:00
|
|
|
maintainers = with maintainers; [ aristid thoughtpolice athas ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|