forked from rarias/jungle
74 lines
1.9 KiB
Nix
74 lines
1.9 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
gcc,
|
|
libgcc,
|
|
overrideCC,
|
|
wrapCCWith,
|
|
}:
|
|
|
|
{
|
|
cc,
|
|
extraPath ? lib.makeBinPath (
|
|
[ gcc.cc ] ++ (lib.optionals (cc.enableCuda or false) [ cc.cudaPackages.cudatoolkit ])
|
|
),
|
|
extraBuildCommands ? "",
|
|
extraInstallCommands ? "",
|
|
}:
|
|
|
|
let
|
|
targetConfig = stdenv.targetPlatform.config;
|
|
in
|
|
(wrapCCWith {
|
|
inherit cc;
|
|
|
|
nixSupport = {
|
|
cc-ldflags = [
|
|
"-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}"
|
|
"-L${gcc.cc.lib}/lib"
|
|
"-L${libgcc.out}/lib"
|
|
"-L${gcc.libc}/lib"
|
|
"-L${cc}/lib"
|
|
];
|
|
cc-cflags = [
|
|
"--gcc-toolchain=${gcc.cc}"
|
|
"-isystem ${cc.original or cc}/lib/clang/${toString cc.llvmMajorVersion}/include"
|
|
"-isystem ${cc}/include"
|
|
"-isystem ${cc}/include/intel64"
|
|
"-isystem ${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}/include"
|
|
];
|
|
libcxx-cxxflags = [
|
|
"-isystem ${gcc.cc}/include/c++/${gcc.version}"
|
|
"-isystem ${gcc.cc}/include/c++/${gcc.version}/${targetConfig}"
|
|
];
|
|
};
|
|
|
|
extraBuildCommands = ''
|
|
# FIXME: We should find a better way to modify the PATH instead of using
|
|
# this ugly hack. See https://jungle.bsc.es/git/rarias/bscpkgs/issues/9
|
|
echo 'path_backup="${extraPath}:$path_backup"' >>$out/nix-support/cc-wrapper-hook
|
|
|
|
# Disable hardening by default
|
|
echo "" > $out/nix-support/add-hardening.sh
|
|
|
|
pushd $ccPath
|
|
for i in $ {llvm,sycl}-* ; do
|
|
ln -s $ccPath/$i $out/bin/$i
|
|
done
|
|
popd
|
|
|
|
# Use this to detect when a compiler subprocess is called
|
|
# from icpx (--fsycl-host-compiler)
|
|
echo 'export NIX_CC_WRAPPER_INTEL=1' >>$out/nix-support/cc-wrapper-hook
|
|
|
|
# oneMath looks for sycl libraries in bin/../lib
|
|
ln -s ${cc}/lib $out/lib
|
|
ln -s ${cc}/include $out/include
|
|
''
|
|
+ extraBuildCommands;
|
|
}).overrideAttrs
|
|
(finalAttrs: prevAttrs: {
|
|
installPhase = prevAttrs.installPhase + extraInstallCommands;
|
|
passthru.stdenv = overrideCC stdenv finalAttrs.finalPackage;
|
|
})
|