Skip to content

Commit

Permalink
cc-wrapper: relocate proprietary-compiler-specific material
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adam Joseph authored and peterhoeg committed Jan 22, 2024
1 parent 5f2a74c commit 1e75516
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
19 changes: 0 additions & 19 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,6 @@ stdenv.mkDerivation {
inherit bintools;
inherit cc libc libcxx nativeTools nativeLibc nativePrefix isGNU isClang;

# Expose the C++ standard library we're using. See the comments on "General
# libc++ support". This is also relevant when using older gcc than the
# stdenv's, as may be required e.g. by CUDAToolkit's nvcc.
cxxStdlib =
let
givenLibcxx = libcxx.isLLVM or false;
givenGccForLibs = useGccForLibs && gccForLibs.langCC or false;
in
if (!givenLibcxx) && givenGccForLibs then
{ kind = "libstdc++"; package = gccForLibs; solib = gccForLibs_solib; }
else if givenLibcxx then
{ kind = "libc++"; package = libcxx; solib = libcxx_solib;}
else
# We're probably using the `libstdc++` that came with our `gcc`.
# TODO: this is maybe not always correct?
# TODO: what happens when `nativeTools = true`?
{ kind = "libstdc++"; package = cc; solib = cc_solib; }
;

emacsBufferSetup = pkgs: ''
; We should handle propagation here too
(mapc
Expand Down
22 changes: 22 additions & 0 deletions pkgs/development/cuda-modules/backend-stdenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,34 @@ let
assertCondition = true;
in

/*
# We should use libstdc++ at least as new as nixpkgs' stdenv's one.
assert let
cxxStdlibCuda = cudaStdenv.cc.cxxStdlib.package;
cxxStdlibNixpkgs = stdenv.cc.cxxStdlib.package;
# Expose the C++ standard library we're using. See the comments on "General
# libc++ support". This is also relevant when using older gcc than the
# stdenv's, as may be required e.g. by CUDAToolkit's nvcc.
cxxStdlib = libcxx:
let
givenLibcxx = libcxx != null && (libcxx.isLLVM or false);
givenGccForLibs = libcxx != null && !(libcxx.isLLVM or false) && (libcxx.isGNU or false);
libcxx_solib = "${lib.getLib libcxx}/lib";
in
if (!givenLibcxx) && givenGccForLibs then
{ kind = "libstdc++"; package = libcxx; solib = libcxx_solib; }
else if givenLibcxx then
{ kind = "libc++"; package = libcxx; solib = libcxx_solib;}
else
# We're probably using the `libstdc++` that came with our `gcc`.
# TODO: this is maybe not always correct?
# TODO: what happens when `nativeTools = true`?
{ kind = "libstdc++"; package = cc; solib = cc_solib; }
;
in
((stdenv.cc.cxxStdlib.kind or null) == "libstdc++")
-> lib.versionAtLeast cxxStdlibCuda.version cxxStdlibNixpkgs.version;
*/

lib.extendDerivation assertCondition passthruExtra cudaStdenv
2 changes: 1 addition & 1 deletion pkgs/development/cuda-modules/cuda/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
useCcForLibs = true;
gccForLibs = ccForLibs-wrapper.cc;
};
cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib;
cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib or (throw "necessary to fix CI");
in
{

Expand Down

0 comments on commit 1e75516

Please sign in to comment.