2020-06-09 18:21:02 +02:00
|
|
|
{
|
|
|
|
stdenv
|
2023-09-28 09:14:36 +02:00
|
|
|
, lib
|
2020-06-17 13:00:49 +02:00
|
|
|
, gcc
|
2020-09-21 17:30:24 +02:00
|
|
|
, clangOmpss2Unwrapped
|
2020-06-17 13:00:49 +02:00
|
|
|
, wrapCCWith
|
2023-09-19 10:33:32 +02:00
|
|
|
, llvmPackages_latest
|
2023-09-28 09:14:36 +02:00
|
|
|
, ompss2rt ? null
|
2020-06-09 18:21:02 +02:00
|
|
|
}:
|
|
|
|
|
2020-06-15 11:54:22 +02:00
|
|
|
|
2020-06-17 13:00:49 +02:00
|
|
|
let
|
2023-09-28 09:14:36 +02:00
|
|
|
homevar = if ompss2rt.pname == "nanos6" then "NANOS6_HOME" else "NODES_HOME";
|
|
|
|
rtname = if ompss2rt.pname == "nanos6" then "libnanos6" else "libnodes";
|
2023-03-06 11:47:01 +01: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.
|
2023-09-19 10:33:32 +02:00
|
|
|
bintools-unwrapped = llvmPackages_latest.tools.bintools-unwrapped.override {
|
2023-03-06 11:47:01 +01:00
|
|
|
lld = clangOmpss2Unwrapped;
|
|
|
|
};
|
2023-09-19 10:33:32 +02:00
|
|
|
bintools = llvmPackages_latest.tools.bintools.override {
|
2023-03-06 11:47:01 +01:00
|
|
|
bintools = bintools-unwrapped;
|
|
|
|
};
|
2020-06-17 13:00:49 +02:00
|
|
|
targetConfig = stdenv.targetPlatform.config;
|
2023-05-22 12:30:23 +02:00
|
|
|
inherit gcc;
|
2020-09-21 17:30:24 +02:00
|
|
|
cc = clangOmpss2Unwrapped;
|
2023-03-06 11:47:01 +01:00
|
|
|
in wrapCCWith {
|
|
|
|
inherit cc bintools;
|
2020-06-17 13:00:49 +02: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 13:21:44 +02:00
|
|
|
echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags
|
2020-07-21 16:31:31 +02: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 13:00:49 +02:00
|
|
|
echo "--gcc-toolchain=${gcc}" >> $out/nix-support/cc-cflags
|
2020-06-10 19:35:11 +02:00
|
|
|
|
2022-02-21 11:51:09 +01:00
|
|
|
wrap clang++ $wrapper $ccPath/clang++
|
2023-09-28 09:14:36 +02:00
|
|
|
'' + 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
|
2023-10-31 10:36:17 +01:00
|
|
|
'' + lib.optionalString (ompss2rt != null && ompss2rt.pname == "nodes") ''
|
|
|
|
echo "export NOSV_HOME=${ompss2rt.nosv}" >> $out/nix-support/cc-wrapper-hook
|
2020-06-09 18:21:02 +02:00
|
|
|
'';
|
|
|
|
}
|
2023-10-31 10:36:17 +01:00
|
|
|
|