cudaPackages.backendStdenv: switch to stdenvAdapters.useLibsFrom
This commit is contained in:
parent
e6e279913c
commit
497f6119e2
2 changed files with 12 additions and 32 deletions
|
@ -2,49 +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
|
||||
ccForLibs = stdenv.cc.cc;
|
||||
cxxStdlib = lib.getLib ccForLibs;
|
||||
nvccCompatibleCC = buildPackages."gcc${gccMajorVersion}".cc;
|
||||
|
||||
cc = wrapCCWith {
|
||||
cc = nvccCompatibleCC;
|
||||
|
||||
# Note: normally the `useCcForLibs`/`gccForLibs` mechanism is used to get a
|
||||
# clang based `cc` to use `libstdc++` (from gcc).
|
||||
|
||||
# Here we (ab)use it to use a `libstdc++` from a different `gcc` than our
|
||||
# `cc`.
|
||||
|
||||
# Note that this does not inhibit our `cc`'s lib dir from being added to
|
||||
# cflags/ldflags (see `cc_solib` in `cc-wrapper`) but this is okay: our
|
||||
# `gccForLibs`'s paths should take precedence.
|
||||
useCcForLibs = true;
|
||||
gccForLibs = ccForLibs;
|
||||
};
|
||||
cudaStdenv = overrideCC stdenv cc;
|
||||
cudaStdenv = stdenvAdapters.useLibsFrom stdenv pkgs."gcc${gccMajorVersion}Stdenv";
|
||||
passthruExtra = {
|
||||
nixpkgsCompatibleLibstdcxx = lib.warn "cudaPackages.backendStdenv.nixpkgsCompatibleLibstdcxx is misnamed, deprecated, and will be removed after 24.05" cxxStdlib;
|
||||
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 ((stdenv.cc.cxxStdlib.kind or null) == "libstdc++")
|
||||
-> lib.versionAtLeast cxxStdlib.version stdenv.cc.cxxStdlib.package.version;
|
||||
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
|
||||
|
|
|
@ -87,8 +87,8 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
|
|||
cuda_nvcc = prev.cuda_nvcc.overrideAttrs (
|
||||
oldAttrs:
|
||||
let
|
||||
# This replicates the logic in backend-stdenv.nix, except the stdenv uses
|
||||
# buildPackages and we use pkgsHostTarget.
|
||||
# This replicates the logic in stdenvAdapters.useLibsFrom, except we use
|
||||
# gcc from pkgsHostTarget and not from buildPackages.
|
||||
ccForLibs-wrapper = final.pkgs.stdenv.cc;
|
||||
gccMajorVersion = final.nvccCompatibilities.${cudaVersion}.gccMaxMajorVersion;
|
||||
cc = final.pkgs.wrapCCWith {
|
||||
|
|
Loading…
Reference in a new issue