2023-11-07 15:35:11 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
nvccCompatibilities,
|
|
|
|
cudaVersion,
|
|
|
|
buildPackages,
|
|
|
|
overrideCC,
|
|
|
|
stdenv,
|
|
|
|
wrapCCWith,
|
|
|
|
}:
|
2023-04-12 21:51:11 +02:00
|
|
|
|
2023-11-07 15:35:11 +01:00
|
|
|
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
|
2023-04-12 21:51:11 +02:00
|
|
|
ccForLibs = stdenv.cc.cc;
|
|
|
|
cxxStdlib = lib.getLib ccForLibs;
|
2023-11-07 15:35:11 +01:00
|
|
|
nvccCompatibleCC = buildPackages."gcc${gccMajorVersion}".cc;
|
|
|
|
|
|
|
|
cc = wrapCCWith {
|
|
|
|
cc = nvccCompatibleCC;
|
|
|
|
|
2023-04-12 21:51:11 +02:00
|
|
|
# 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;
|
2023-11-07 15:35:11 +01:00
|
|
|
};
|
|
|
|
cudaStdenv = overrideCC stdenv cc;
|
|
|
|
passthruExtra = {
|
2023-04-12 21:51:11 +02:00
|
|
|
nixpkgsCompatibleLibstdcxx = lib.warn "cudaPackages.backendStdenv.nixpkgsCompatibleLibstdcxx is misnamed, deprecated, and will be removed after 24.05" cxxStdlib;
|
2023-11-07 15:35:11 +01:00
|
|
|
# cc already exposed
|
|
|
|
};
|
|
|
|
assertCondition = true;
|
|
|
|
in
|
2023-04-12 21:51:11 +02:00
|
|
|
|
|
|
|
# We should use libstdc++ at least as new as nixpkgs' stdenv's one.
|
|
|
|
assert ((stdenv.cc.cxxStdlib.kind or null) == "libstdc++")
|
2024-01-11 00:23:05 +01:00
|
|
|
-> lib.versionAtLeast cxxStdlib.version stdenv.cc.cxxStdlib.package.version;
|
2023-04-12 21:51:11 +02:00
|
|
|
|
2023-11-07 15:35:11 +01:00
|
|
|
lib.extendDerivation assertCondition passthruExtra cudaStdenv
|