bscpkgs/pkgs/llvm-ompss2/default.nix

68 lines
2.4 KiB
Nix
Raw Normal View History

2020-06-10 00:21:02 +08:00
{
stdenv
, lib
2020-06-17 19:00:49 +08:00
, gcc
2020-09-21 23:30:24 +08:00
, clangOmpss2Unwrapped
, openmp ? null
2020-06-17 19:00:49 +08:00
, wrapCCWith
, llvmPackages_latest
, ompss2rt ? null
2020-06-10 00:21:02 +08:00
}:
let
usingNodesAndOmpv = (openmp.pname == "openmp-v" && ompss2rt.pname == "nodes");
sameNosv = openmp.nosv == ompss2rt.nosv;
in
assert lib.assertMsg (usingNodesAndOmpv -> sameNosv) "OpenMP-V and NODES must share the same nOS-V";
2020-06-15 17:54:22 +08:00
2020-06-17 19:00:49 +08:00
let
homevar = if ompss2rt.pname == "nanos6" then "NANOS6_HOME" else "NODES_HOME";
rtname = if ompss2rt.pname == "nanos6" then "libnanos6" else "libnodes";
ompname = if openmp.pname == "openmp-v" then "libompv" else "libomp";
2023-03-06 18:47:01 +08:00
# We need to replace the lld linker from bintools with our linker just built,
# otherwise we run into incompatibility issues when mixing compiler and linker
# versions.
bintools-unwrapped = llvmPackages_latest.tools.bintools-unwrapped.override {
2023-03-06 18:47:01 +08:00
lld = clangOmpss2Unwrapped;
};
bintools = llvmPackages_latest.tools.bintools.override {
2023-03-06 18:47:01 +08:00
bintools = bintools-unwrapped;
};
2020-06-17 19:00:49 +08:00
targetConfig = stdenv.targetPlatform.config;
inherit gcc;
2020-09-21 23:30:24 +08:00
cc = clangOmpss2Unwrapped;
2023-03-06 18:47:01 +08:00
in wrapCCWith {
inherit cc bintools;
# extraPackages adds packages to depsTargetTargetPropagated
extraPackages = lib.optional (openmp != null) openmp;
2020-06-17 19:00:49 +08:00
extraBuildCommands = ''
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
2020-06-17 19:21:44 +08:00
echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags
2020-07-21 22:31:31 +08:00
for dir in ${gcc.cc}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done
for dir in ${gcc.cc}/include/c++/*/${targetConfig}; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done
2020-06-17 19:00:49 +08:00
echo "--gcc-toolchain=${gcc}" >> $out/nix-support/cc-cflags
2020-06-11 01:35:11 +08:00
2022-02-21 18:51:09 +08:00
wrap clang++ $wrapper $ccPath/clang++
'' + lib.optionalString (openmp != null) ''
echo "export OPENMP_RUNTIME=${ompname}" >> $out/nix-support/cc-wrapper-hook
'' + lib.optionalString (ompss2rt != null) ''
echo "export OMPSS2_RUNTIME=${rtname}" >> $out/nix-support/cc-wrapper-hook
echo "export ${homevar}=${ompss2rt}" >> $out/nix-support/cc-wrapper-hook
'' + lib.optionalString (ompss2rt != null && ompss2rt.pname == "nodes") ''
echo "export NOSV_HOME=${ompss2rt.nosv}" >> $out/nix-support/cc-wrapper-hook
2020-06-10 00:21:02 +08:00
'';
}