{ stdenv , lib , gcc , clangOmpss2Unwrapped , openmp , useOpenmp ? false , openmpv , useOpenmpV ? false , nanos6 , useNanos6 ? false , nodes , useNodes ? false , wrapCCWith , llvmPackages_latest }: with lib; let getSplice = target: pkg: if pkg ? "__spliced" && pkg.__spliced ? target then pkg.__spliced."${target}" else pkg; getSpliceTargetTarget = getSplice "targetTarget"; omp = if useOpenmp then openmp else if useOpenmpV then openmpv else null; ompss2rtUnspliced = if useNanos6 then nanos6 else if useNodes then nodes else null; ompss2rt = getSpliceTargetTarget ompss2rtUnspliced; usingNodesAndOmpv = omp != null && ompss2rt != null && (omp.pname == "openmp-v" && ompss2rt.pname == "nodes"); sameNosvUnspliced = omp != null && ompss2rtUnspliced != null && omp.nosv == ompss2rtUnspliced.nosv; sameNosvSpliced = (getSpliceTargetTarget omp.nosv) == ompss2rt.nosv; in assert assertMsg (usingNodesAndOmpv -> sameNosvUnspliced) "OpenMP-V and NODES must share the same nOS-V before splice"; assert assertMsg (usingNodesAndOmpv -> sameNosvSpliced) "OpenMP-V and NODES must share the same nOS-V after splice"; assert assertMsg (useOpenmp -> !useOpenmpV) "Either OpenMP or OpenMP-V may be enabled, but not both"; assert assertMsg (useNanos6 -> !useNodes) "Either Nanos6 or NODES may be enabled, but not both"; let homevar = if ompss2rt.pname == "nanos6" then "NANOS6_HOME" else "NODES_HOME"; rtname = if ompss2rt.pname == "nanos6" then "libnanos6" else "libnodes"; ompname = if omp.pname == "openmp-v" then "libompv" else "libomp"; # 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.bintools-unwrapped.override { lld = clangOmpss2Unwrapped; }; bintools = llvmPackages_latest.bintools.override { bintools = bintools-unwrapped; }; targetConfig = stdenv.targetPlatform.config; inherit gcc; cc = clangOmpss2Unwrapped; gccVersion = with versions; let v = gcc.version; in concatStringsSep "." [(major v) (minor v) (patch v)]; in (wrapCCWith { inherit cc bintools; # extraPackages adds packages to depsTargetTargetPropagated extraPackages = optional (omp != null) omp; extraBuildCommands = '' echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-cflags echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gccVersion}" >> $out/nix-support/cc-ldflags echo "-L${gcc.cc.lib}/lib" >> $out/nix-support/cc-ldflags 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 echo "--gcc-toolchain=${gcc}" >> $out/nix-support/cc-cflags wrap ${targetConfig}clang++ $wrapper $ccPath/clang++ wrap ${targetConfig}clang $wrapper $ccPath/clang '' + optionalString (omp != null) '' echo "export OPENMP_RUNTIME=${ompname}" >> $out/nix-support/cc-wrapper-hook '' + optionalString (ompss2rt != null) '' echo "export OMPSS2_RUNTIME=${rtname}" >> $out/nix-support/cc-wrapper-hook echo "export ${homevar}=${ompss2rt}" >> $out/nix-support/cc-wrapper-hook '' + optionalString (ompss2rt != null && ompss2rt.pname == "nodes") '' echo "export NOSV_HOME=${ompss2rt}" >> $out/nix-support/cc-wrapper-hook ''; }).overrideAttrs (prev: { passthru = (prev.passthru or {}) // { inherit ompss2rt; }; })