2021-04-03 16:30:16 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch
|
2023-06-14 21:19:10 +00:00
|
|
|
, cmake, which, m4, python3, bison, flex, llvmPackages, ncurses, xcode, tbb
|
2020-04-24 15:50:56 +00:00
|
|
|
# the default test target is sse4, but that is not supported by all Hydra agents
|
2022-12-30 19:11:59 +00:00
|
|
|
, testedTargets ? if stdenv.isAarch64 || stdenv.isAarch32 then [ "neon-i32x4" ] else [ "sse2-i32x4" ]
|
2016-09-04 15:03:34 +00:00
|
|
|
}:
|
2015-11-28 20:28:27 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 15:50:56 +00:00
|
|
|
pname = "ispc";
|
2023-10-12 13:45:21 +00:00
|
|
|
version = "1.21.1";
|
2015-11-28 20:28:27 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-04-24 15:50:56 +00:00
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2022-05-15 10:48:25 +00:00
|
|
|
rev = "v${version}";
|
2023-10-12 13:45:21 +00:00
|
|
|
sha256 = "sha256-QnGD27f1GWcuyFxFtzm1f7U/ng7VHZKSeSTcKINO/SA=";
|
2015-11-28 20:28:27 +00:00
|
|
|
};
|
|
|
|
|
2023-06-14 21:19:10 +00:00
|
|
|
nativeBuildInputs = [ cmake which m4 bison flex python3 llvmPackages.libllvm.dev tbb ] ++ lib.lists.optionals stdenv.isDarwin [ xcode ];
|
|
|
|
|
2015-11-28 20:28:27 +00:00
|
|
|
buildInputs = with llvmPackages; [
|
2022-05-15 10:48:25 +00:00
|
|
|
libllvm libclang openmp ncurses
|
2015-11-28 20:28:27 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 15:50:56 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace CMakeLists.txt \
|
2022-05-15 10:48:25 +00:00
|
|
|
--replace CURSES_CURSES_LIBRARY CURSES_NCURSES_LIBRARY
|
2020-04-24 15:50:56 +00:00
|
|
|
substituteInPlace cmake/GenerateBuiltins.cmake \
|
|
|
|
--replace 'bit 32 64' 'bit 64'
|
|
|
|
'';
|
|
|
|
|
|
|
|
inherit testedTargets;
|
2015-11-28 20:28:27 +00:00
|
|
|
|
2023-06-16 18:00:55 +00:00
|
|
|
doCheck = true;
|
2020-04-24 15:50:56 +00:00
|
|
|
|
|
|
|
# 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" ];
|
2016-09-04 13:56:07 +00:00
|
|
|
|
2015-11-28 20:28:27 +00:00
|
|
|
checkPhase = ''
|
2019-10-09 11:17:01 +00:00
|
|
|
export ISPC_HOME=$PWD/bin
|
2016-09-04 15:03:34 +00:00
|
|
|
for target in $testedTargets
|
|
|
|
do
|
|
|
|
echo "Testing target $target"
|
|
|
|
echo "================================"
|
|
|
|
echo
|
2019-10-09 11:17:01 +00:00
|
|
|
(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)
|
2016-09-04 15:03:34 +00:00
|
|
|
done
|
2015-11-28 20:28:27 +00:00
|
|
|
'';
|
|
|
|
|
2019-10-09 11:17:01 +00:00
|
|
|
cmakeFlags = [
|
2023-06-14 21:19:10 +00:00
|
|
|
"-DFILE_CHECK_EXECUTABLE=${llvmPackages.llvm}/bin/FileCheck"
|
|
|
|
"-DLLVM_AS_EXECUTABLE=${llvmPackages.llvm}/bin/llvm-as"
|
2021-05-08 23:27:53 +00:00
|
|
|
"-DLLVM_CONFIG_EXECUTABLE=${llvmPackages.llvm.dev}/bin/llvm-config"
|
2023-06-14 21:19:10 +00:00
|
|
|
"-DLLVM_DIS_EXECUTABLE=${llvmPackages.llvm}/bin/llvm-dis"
|
2019-10-09 11:17:01 +00:00
|
|
|
"-DCLANG_EXECUTABLE=${llvmPackages.clang}/bin/clang"
|
2021-04-03 16:30:16 +00:00
|
|
|
"-DCLANGPP_EXECUTABLE=${llvmPackages.clang}/bin/clang++"
|
2019-10-09 11:17:01 +00:00
|
|
|
"-DISPC_INCLUDE_EXAMPLES=OFF"
|
|
|
|
"-DISPC_INCLUDE_UTILS=OFF"
|
2022-12-30 19:11:59 +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"))
|
2023-06-16 18:00:55 +00:00
|
|
|
] ++ lib.lists.optionals stdenv.isDarwin [
|
|
|
|
"-DISPC_MACOS_SDK_PATH=${xcode}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
2020-04-24 15:50:56 +00:00
|
|
|
];
|
2015-11-28 20:28:27 +00:00
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 15:50:56 +00:00
|
|
|
homepage = "https://ispc.github.io/";
|
2015-11-28 20:28:27 +00:00
|
|
|
description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language";
|
2020-04-24 15:50:56 +00:00
|
|
|
license = licenses.bsd3;
|
2022-12-30 19:11:59 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; # TODO: buildable on more platforms?
|
2023-08-29 01:59:33 +00:00
|
|
|
maintainers = with maintainers; [ aristid thoughtpolice athas alexfmpe ];
|
2015-11-28 20:28:27 +00:00
|
|
|
};
|
|
|
|
}
|