···18 # E.g. for cudaPackages_11_8 we use gcc11 with gcc12's libstdc++
19 # Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
20 backendStdenv = final.callPackage ./stdenv.nix {
21- nixpkgsStdenv = prev.pkgs.stdenv;
22- nvccCompatibleStdenv = prev.pkgs.buildPackages."${finalVersion.gcc}Stdenv";
00000023 };
2425 ### Add classic cudatoolkit package
···18 # E.g. for cudaPackages_11_8 we use gcc11 with gcc12's libstdc++
19 # Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
20 backendStdenv = final.callPackage ./stdenv.nix {
21+ # We use buildPackages (= pkgsBuildHost) because we look for a gcc that
22+ # runs on our build platform, and that produces executables for the host
23+ # platform (= platform on which we deploy and run the downstream packages).
24+ # The target platform of buildPackages.gcc is our host platform, so its
25+ # .lib output should be the libstdc++ we want to be writing in the runpaths
26+ # Cf. https://github.com/NixOS/nixpkgs/pull/225661#discussion_r1164564576
27+ nixpkgsCompatibleLibstdcxx = final.pkgs.buildPackages.gcc.cc.lib;
28+ nvccCompatibleCC = final.pkgs.buildPackages."${finalVersion.gcc}".cc;
29 };
3031 ### Add classic cudatoolkit package
+28-12
pkgs/development/compilers/cudatoolkit/stdenv.nix
···1-{ nixpkgsStdenv
2-, nvccCompatibleStdenv
03, overrideCC
04, wrapCCWith
5}:
67-overrideCC nixpkgsStdenv (wrapCCWith {
8- cc = nvccCompatibleStdenv.cc.cc;
00910- # This option is for clang's libcxx, but we (ab)use it for gcc's libstdc++.
11- # Note that libstdc++ maintains forward-compatibility: if we load a newer
12- # libstdc++ into the process, we can still use libraries built against an
13- # older libstdc++. This, in practice, means that we should use libstdc++ from
14- # the same stdenv that the rest of nixpkgs uses.
15- # We currently do not try to support anything other than gcc and linux.
16- libcxx = nixpkgsStdenv.cc.cc.lib;
17-})
000000000000
···1+{ lib
2+, nixpkgsCompatibleLibstdcxx
3+, nvccCompatibleCC
4, overrideCC
5+, stdenv
6, wrapCCWith
7}:
89+let
10+ cc = wrapCCWith
11+ {
12+ cc = nvccCompatibleCC;
1314+ # This option is for clang's libcxx, but we (ab)use it for gcc's libstdc++.
15+ # Note that libstdc++ maintains forward-compatibility: if we load a newer
16+ # libstdc++ into the process, we can still use libraries built against an
17+ # older libstdc++. This, in practice, means that we should use libstdc++ from
18+ # the same stdenv that the rest of nixpkgs uses.
19+ # We currently do not try to support anything other than gcc and linux.
20+ libcxx = nixpkgsCompatibleLibstdcxx;
21+ };
22+ cudaStdenv = overrideCC stdenv cc;
23+ passthruExtra = {
24+ inherit nixpkgsCompatibleLibstdcxx;
25+ # cc already exposed
26+ };
27+ assertCondition = true;
28+in
29+lib.extendDerivation
30+ assertCondition
31+ passthruExtra
32+ cudaStdenv
33+