diff options
Diffstat (limited to 'nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix')
-rw-r--r-- | nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix b/nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix index 10fedd1e6f27..3b4c8d47c5e8 100644 --- a/nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix +++ b/nixpkgs/pkgs/development/cuda-modules/backend-stdenv.nix @@ -2,38 +2,29 @@ lib, nvccCompatibilities, cudaVersion, - buildPackages, + pkgs, overrideCC, stdenv, wrapCCWith, + stdenvAdapters, }: + let gccMajorVersion = nvccCompatibilities.${cudaVersion}.gccMaxMajorVersion; - # We use buildPackages (= pkgsBuildHost) because we look for a gcc that - # runs on our build platform, and that produces executables for the host - # platform (= platform on which we deploy and run the downstream packages). - # The target platform of buildPackages.gcc is our host platform, so its - # .lib output should be the libstdc++ we want to be writing in the runpaths - # Cf. https://github.com/NixOS/nixpkgs/pull/225661#discussion_r1164564576 - nixpkgsCompatibleLibstdcxx = buildPackages.gcc.cc.lib; - nvccCompatibleCC = buildPackages."gcc${gccMajorVersion}".cc; - - cc = wrapCCWith { - cc = nvccCompatibleCC; - - # This option is for clang's libcxx, but we (ab)use it for gcc's libstdc++. - # Note that libstdc++ maintains forward-compatibility: if we load a newer - # libstdc++ into the process, we can still use libraries built against an - # older libstdc++. This, in practice, means that we should use libstdc++ from - # the same stdenv that the rest of nixpkgs uses. - # We currently do not try to support anything other than gcc and linux. - libcxx = nixpkgsCompatibleLibstdcxx; - }; - cudaStdenv = overrideCC stdenv cc; + cudaStdenv = stdenvAdapters.useLibsFrom stdenv pkgs."gcc${gccMajorVersion}Stdenv"; passthruExtra = { - inherit nixpkgsCompatibleLibstdcxx; + nixpkgsCompatibleLibstdcxx = lib.warn "cudaPackages.backendStdenv.nixpkgsCompatibleLibstdcxx is misnamed, deprecated, and will be removed after 24.05" cudaStdenv.cc.cxxStdlib.package; # cc already exposed }; assertCondition = true; in + +# We should use libstdc++ at least as new as nixpkgs' stdenv's one. +assert let + cxxStdlibCuda = cudaStdenv.cc.cxxStdlib.package; + cxxStdlibNixpkgs = stdenv.cc.cxxStdlib.package; +in +((stdenv.cc.cxxStdlib.kind or null) == "libstdc++") +-> lib.versionAtLeast cxxStdlibCuda.version cxxStdlibNixpkgs.version; + lib.extendDerivation assertCondition passthruExtra cudaStdenv |