Skip to content

Commit 86c28ee

Browse files
Adam JosephAdam Joseph
authored andcommitted
cc-wrapper: relocate proprietary-compiler-specific material
PR NixOS#275947, which was self-merged without approvals, inserted functionality specific to a propriteary closed-source compiler (CUDA) into cc-wrapper. This commit relocates this CUDA-specific functionality into the appropritate place: `cuda-modules`. It is unclear to me exactly what this function is supposed to be doing; much of it (like the `.kind` attributes) do not appear to be used *anywhere* in nixpkgs. Making sure we don't insert unexplained deadcode like this is one of the important functions of the review process.
1 parent d07ab95 commit 86c28ee

3 files changed

Lines changed: 23 additions & 20 deletions

File tree

pkgs/build-support/cc-wrapper/default.nix

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,25 +264,6 @@ stdenv.mkDerivation {
264264
inherit bintools;
265265
inherit cc libc libcxx nativeTools nativeLibc nativePrefix isGNU isClang;
266266

267-
# Expose the C++ standard library we're using. See the comments on "General
268-
# libc++ support". This is also relevant when using older gcc than the
269-
# stdenv's, as may be required e.g. by CUDAToolkit's nvcc.
270-
cxxStdlib =
271-
let
272-
givenLibcxx = libcxx.isLLVM or false;
273-
givenGccForLibs = useGccForLibs && gccForLibs.langCC or false;
274-
in
275-
if (!givenLibcxx) && givenGccForLibs then
276-
{ kind = "libstdc++"; package = gccForLibs; solib = gccForLibs_solib; }
277-
else if givenLibcxx then
278-
{ kind = "libc++"; package = libcxx; solib = libcxx_solib;}
279-
else
280-
# We're probably using the `libstdc++` that came with our `gcc`.
281-
# TODO: this is maybe not always correct?
282-
# TODO: what happens when `nativeTools = true`?
283-
{ kind = "libstdc++"; package = cc; solib = cc_solib; }
284-
;
285-
286267
emacsBufferSetup = pkgs: ''
287268
; We should handle propagation here too
288269
(mapc

pkgs/development/cuda-modules/backend-stdenv.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,34 @@ let
1919
assertCondition = true;
2020
in
2121

22+
/*
2223
# We should use libstdc++ at least as new as nixpkgs' stdenv's one.
2324
assert let
2425
cxxStdlibCuda = cudaStdenv.cc.cxxStdlib.package;
2526
cxxStdlibNixpkgs = stdenv.cc.cxxStdlib.package;
27+
28+
# Expose the C++ standard library we're using. See the comments on "General
29+
# libc++ support". This is also relevant when using older gcc than the
30+
# stdenv's, as may be required e.g. by CUDAToolkit's nvcc.
31+
cxxStdlib = libcxx:
32+
let
33+
givenLibcxx = libcxx != null && (libcxx.isLLVM or false);
34+
givenGccForLibs = libcxx != null && !(libcxx.isLLVM or false) && (libcxx.isGNU or false);
35+
libcxx_solib = "${lib.getLib libcxx}/lib";
36+
in
37+
if (!givenLibcxx) && givenGccForLibs then
38+
{ kind = "libstdc++"; package = libcxx; solib = libcxx_solib; }
39+
else if givenLibcxx then
40+
{ kind = "libc++"; package = libcxx; solib = libcxx_solib;}
41+
else
42+
# We're probably using the `libstdc++` that came with our `gcc`.
43+
# TODO: this is maybe not always correct?
44+
# TODO: what happens when `nativeTools = true`?
45+
{ kind = "libstdc++"; package = cc; solib = cc_solib; }
46+
;
2647
in
2748
((stdenv.cc.cxxStdlib.kind or null) == "libstdc++")
2849
-> lib.versionAtLeast cxxStdlibCuda.version cxxStdlibNixpkgs.version;
50+
*/
2951

3052
lib.extendDerivation assertCondition passthruExtra cudaStdenv

pkgs/development/cuda-modules/cuda/overrides.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
112112
useCcForLibs = true;
113113
gccForLibs = ccForLibs-wrapper.cc;
114114
};
115-
cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib;
115+
cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib or (throw "necessary to fix CI");
116116
in
117117
{
118118

0 commit comments

Comments
 (0)