···2929, python3 # FIXME: CUDAToolkit 10 may still need python27
3030, pulseaudio
3131, requireFile
3232+, stdenv
3233, backendStdenv # E.g. gcc11Stdenv, set in extension.nix
3334, unixODBC
3435, wayland
···136137 (placeholder "lib")
137138 (placeholder "out")
138139 "${placeholder "out"}/nvvm"
139139- # Is it not handled by autoPatchelf automatically?
140140- "${lib.getLib backendStdenv.cc.cc}/lib64"
140140+ # NOTE: use the same libstdc++ as the rest of nixpkgs, not from backendStdenv
141141+ "${lib.getLib stdenv.cc.cc}/lib64"
141142 "${placeholder "out"}/jre/lib/amd64/jli"
142143 "${placeholder "out"}/lib64"
143144 "${placeholder "out"}/nvvm/lib64"
···219220220221 mv pkg/builds/nsight_systems/target-linux-x64 $out/target-linux-x64
221222 mv pkg/builds/nsight_systems/host-linux-x64 $out/host-linux-x64
223223+ rm $out/host-linux-x64/libstdc++.so*
222224 ''}
223225 ${lib.optionalString (lib.versionAtLeast version "11.8")
224226 # error: auto-patchelf could not satisfy dependency libtiff.so.5 wanted by /nix/store/.......-cudatoolkit-12.0.1/host-linux-x64/Plugins/imageformats/libqtiff.so
···1010 finalVersion = cudatoolkitVersions.${final.cudaVersion};
11111212 # Exposed as cudaPackages.backendStdenv.
1313- # We don't call it just "stdenv" to avoid confusion: e.g. this toolchain doesn't contain nvcc.
1414- # Instead, it's the back-end toolchain for nvcc to use.
1515- # We also use this to link a compatible libstdc++ (backendStdenv.cc.cc.lib)
1313+ # This is what nvcc uses as a backend,
1414+ # and it has to be an officially supported one (e.g. gcc11 for cuda11).
1515+ #
1616+ # It, however, propagates current stdenv's libstdc++ to avoid "GLIBCXX_* not found errors"
1717+ # when linked with other C++ libraries.
1818+ # E.g. for cudaPackages_11_8 we use gcc11 with gcc12's libstdc++
1619 # Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
1717- backendStdenv = prev.pkgs."${finalVersion.gcc}Stdenv";
2020+ backendStdenv = final.callPackage ./stdenv.nix {
2121+ nixpkgsStdenv = prev.pkgs.stdenv;
2222+ nvccCompatibleStdenv = prev.pkgs.buildPackages."${finalVersion.gcc}Stdenv";
2323+ };
18241925 ### Add classic cudatoolkit package
2026 cudatoolkit =
···11{ lib
22+, stdenv
23, backendStdenv
34, fetchurl
45, autoPatchelfHook
···3031 ];
31323233 buildInputs = [
3333- # autoPatchelfHook will search for a libstdc++ and we're giving it a
3434- # "compatible" libstdc++ from the same toolchain that NVCC uses.
3535- #
3434+ # autoPatchelfHook will search for a libstdc++ and we're giving it
3535+ # one that is compatible with the rest of nixpkgs, even when
3636+ # nvcc forces us to use an older gcc
3637 # NB: We don't actually know if this is the right thing to do
3737- backendStdenv.cc.cc.lib
3838+ stdenv.cc.cc.lib
3839 ];
39404041 dontBuild = true;
+17
pkgs/development/compilers/cudatoolkit/stdenv.nix
···11+{ nixpkgsStdenv
22+, nvccCompatibleStdenv
33+, overrideCC
44+, wrapCCWith
55+}:
66+77+overrideCC nixpkgsStdenv (wrapCCWith {
88+ cc = nvccCompatibleStdenv.cc.cc;
99+1010+ # 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+})