···1818 # E.g. for cudaPackages_11_8 we use gcc11 with gcc12's libstdc++
1919 # Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
2020 backendStdenv = final.callPackage ./stdenv.nix {
2121- nixpkgsStdenv = prev.pkgs.stdenv;
2222- nvccCompatibleStdenv = prev.pkgs.buildPackages."${finalVersion.gcc}Stdenv";
2121+ # We use buildPackages (= pkgsBuildHost) because we look for a gcc that
2222+ # runs on our build platform, and that produces executables for the host
2323+ # platform (= platform on which we deploy and run the downstream packages).
2424+ # The target platform of buildPackages.gcc is our host platform, so its
2525+ # .lib output should be the libstdc++ we want to be writing in the runpaths
2626+ # Cf. https://github.com/NixOS/nixpkgs/pull/225661#discussion_r1164564576
2727+ nixpkgsCompatibleLibstdcxx = final.pkgs.buildPackages.gcc.cc.lib;
2828+ nvccCompatibleCC = final.pkgs.buildPackages."${finalVersion.gcc}".cc;
2329 };
24302531 ### Add classic cudatoolkit package
+28-12
pkgs/development/compilers/cudatoolkit/stdenv.nix
···11-{ nixpkgsStdenv
22-, nvccCompatibleStdenv
11+{ lib
22+, nixpkgsCompatibleLibstdcxx
33+, nvccCompatibleCC
34, overrideCC
55+, stdenv
46, wrapCCWith
57}:
6877-overrideCC nixpkgsStdenv (wrapCCWith {
88- cc = nvccCompatibleStdenv.cc.cc;
99+let
1010+ cc = wrapCCWith
1111+ {
1212+ cc = nvccCompatibleCC;
9131010- # This option is for clang's libcxx, but we (ab)use it for gcc's libstdc++.
1111- # Note that libstdc++ maintains forward-compatibility: if we load a newer
1212- # libstdc++ into the process, we can still use libraries built against an
1313- # older libstdc++. This, in practice, means that we should use libstdc++ from
1414- # the same stdenv that the rest of nixpkgs uses.
1515- # We currently do not try to support anything other than gcc and linux.
1616- libcxx = nixpkgsStdenv.cc.cc.lib;
1717-})
1414+ # This option is for clang's libcxx, but we (ab)use it for gcc's libstdc++.
1515+ # Note that libstdc++ maintains forward-compatibility: if we load a newer
1616+ # libstdc++ into the process, we can still use libraries built against an
1717+ # older libstdc++. This, in practice, means that we should use libstdc++ from
1818+ # the same stdenv that the rest of nixpkgs uses.
1919+ # We currently do not try to support anything other than gcc and linux.
2020+ libcxx = nixpkgsCompatibleLibstdcxx;
2121+ };
2222+ cudaStdenv = overrideCC stdenv cc;
2323+ passthruExtra = {
2424+ inherit nixpkgsCompatibleLibstdcxx;
2525+ # cc already exposed
2626+ };
2727+ assertCondition = true;
2828+in
2929+lib.extendDerivation
3030+ assertCondition
3131+ passthruExtra
3232+ cudaStdenv
3333+