Merge pull request #223664 from SomeoneSerge/cuda-libstdcpp
cudaPackages: use the same libstdc++ as the rest of nixpkgs
This commit is contained in:
commit
cd07e0258c
6 changed files with 45 additions and 15 deletions
|
@ -29,6 +29,7 @@ args@
|
|||
, python3 # FIXME: CUDAToolkit 10 may still need python27
|
||||
, pulseaudio
|
||||
, requireFile
|
||||
, stdenv
|
||||
, backendStdenv # E.g. gcc11Stdenv, set in extension.nix
|
||||
, unixODBC
|
||||
, wayland
|
||||
|
@ -136,8 +137,8 @@ backendStdenv.mkDerivation rec {
|
|||
(placeholder "lib")
|
||||
(placeholder "out")
|
||||
"${placeholder "out"}/nvvm"
|
||||
# Is it not handled by autoPatchelf automatically?
|
||||
"${lib.getLib backendStdenv.cc.cc}/lib64"
|
||||
# NOTE: use the same libstdc++ as the rest of nixpkgs, not from backendStdenv
|
||||
"${lib.getLib stdenv.cc.cc}/lib64"
|
||||
"${placeholder "out"}/jre/lib/amd64/jli"
|
||||
"${placeholder "out"}/lib64"
|
||||
"${placeholder "out"}/nvvm/lib64"
|
||||
|
@ -219,6 +220,7 @@ backendStdenv.mkDerivation rec {
|
|||
|
||||
mv pkg/builds/nsight_systems/target-linux-x64 $out/target-linux-x64
|
||||
mv pkg/builds/nsight_systems/host-linux-x64 $out/host-linux-x64
|
||||
rm $out/host-linux-x64/libstdc++.so*
|
||||
''}
|
||||
${lib.optionalString (lib.versionAtLeast version "11.8")
|
||||
# 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
|
||||
|
|
|
@ -10,11 +10,17 @@ final: prev: let
|
|||
finalVersion = cudatoolkitVersions.${final.cudaVersion};
|
||||
|
||||
# Exposed as cudaPackages.backendStdenv.
|
||||
# We don't call it just "stdenv" to avoid confusion: e.g. this toolchain doesn't contain nvcc.
|
||||
# Instead, it's the back-end toolchain for nvcc to use.
|
||||
# We also use this to link a compatible libstdc++ (backendStdenv.cc.cc.lib)
|
||||
# This is what nvcc uses as a backend,
|
||||
# and it has to be an officially supported one (e.g. gcc11 for cuda11).
|
||||
#
|
||||
# It, however, propagates current stdenv's libstdc++ to avoid "GLIBCXX_* not found errors"
|
||||
# when linked with other C++ libraries.
|
||||
# E.g. for cudaPackages_11_8 we use gcc11 with gcc12's libstdc++
|
||||
# Cf. https://github.com/NixOS/nixpkgs/pull/218265 for context
|
||||
backendStdenv = prev.pkgs."${finalVersion.gcc}Stdenv";
|
||||
backendStdenv = final.callPackage ./stdenv.nix {
|
||||
nixpkgsStdenv = prev.pkgs.stdenv;
|
||||
nvccCompatibleStdenv = prev.pkgs.buildPackages."${finalVersion.gcc}Stdenv";
|
||||
};
|
||||
|
||||
### Add classic cudatoolkit package
|
||||
cudatoolkit =
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, backendStdenv
|
||||
, fetchurl
|
||||
, autoPatchelfHook
|
||||
|
@ -30,11 +31,11 @@ backendStdenv.mkDerivation {
|
|||
];
|
||||
|
||||
buildInputs = [
|
||||
# autoPatchelfHook will search for a libstdc++ and we're giving it a
|
||||
# "compatible" libstdc++ from the same toolchain that NVCC uses.
|
||||
#
|
||||
# autoPatchelfHook will search for a libstdc++ and we're giving it
|
||||
# one that is compatible with the rest of nixpkgs, even when
|
||||
# nvcc forces us to use an older gcc
|
||||
# NB: We don't actually know if this is the right thing to do
|
||||
backendStdenv.cc.cc.lib
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
|
||||
dontBuild = true;
|
||||
|
|
17
pkgs/development/compilers/cudatoolkit/stdenv.nix
Normal file
17
pkgs/development/compilers/cudatoolkit/stdenv.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ nixpkgsStdenv
|
||||
, nvccCompatibleStdenv
|
||||
, overrideCC
|
||||
, wrapCCWith
|
||||
}:
|
||||
|
||||
overrideCC nixpkgsStdenv (wrapCCWith {
|
||||
cc = nvccCompatibleStdenv.cc.cc;
|
||||
|
||||
# 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 = nixpkgsStdenv.cc.cc.lib;
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
{ stdenv,
|
||||
backendStdenv,
|
||||
lib,
|
||||
zlib,
|
||||
|
@ -26,7 +26,6 @@
|
|||
maxCudaVersion,
|
||||
}:
|
||||
assert useCudatoolkitRunfile || (libcublas != null); let
|
||||
inherit (backendStdenv) cc;
|
||||
inherit (lib) lists strings trivial versions;
|
||||
|
||||
# majorMinorPatch :: String -> String
|
||||
|
@ -63,7 +62,10 @@ in
|
|||
|
||||
# Used by autoPatchelfHook
|
||||
buildInputs = [
|
||||
cc.cc.lib # libstdc++
|
||||
# Note this libstdc++ isn't from the (possibly older) nvcc-compatible
|
||||
# stdenv, but from the (newer) stdenv that the rest of nixpkgs uses
|
||||
stdenv.cc.cc.lib
|
||||
|
||||
zlib
|
||||
cudatoolkit_root
|
||||
];
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
builtins.head optLevels
|
||||
, faiss # To run demos in the tests
|
||||
, runCommand
|
||||
}:
|
||||
}@inputs:
|
||||
|
||||
assert cudaSupport -> nvidia-thrust.cudaSupport;
|
||||
|
||||
|
@ -33,9 +33,11 @@ let
|
|||
pname = "faiss";
|
||||
version = "1.7.2";
|
||||
|
||||
inherit (cudaPackages) cudaFlags;
|
||||
inherit (cudaPackages) cudaFlags backendStdenv;
|
||||
inherit (cudaFlags) cudaCapabilities dropDot;
|
||||
|
||||
stdenv = if cudaSupport then backendStdenv else inputs.stdenv;
|
||||
|
||||
cudaJoined = symlinkJoin {
|
||||
name = "cuda-packages-unsplit";
|
||||
paths = with cudaPackages; [
|
||||
|
|
Loading…
Reference in a new issue