Skip to content

Commit

Permalink
cc-wrapper: cxxStdlib: expose solib and package separately
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeoneSerge committed Jan 12, 2024
1 parent 210ce38 commit 8eda4c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ let
gccForLibs_solib = getLib gccForLibs
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}";

# Analogously to cc_solib and gccForLibs_solib
libcxx_solib = "${lib.getLib libcxx}/lib";

# The following two functions, `isGccArchSupported` and
# `isGccTuneSupported`, only handle those situations where a flag
# (`-march` or `-mtune`) is accepted by one compiler but rejected
Expand Down Expand Up @@ -270,14 +273,14 @@ stdenv.mkDerivation {
givenGccForLibs = useGccForLibs && gccForLibs.langCC or false;
in
if (!givenLibcxx) && givenGccForLibs then
{ kind = "libstdc++"; lib = gccForLibs; }
{ kind = "libstdc++"; package = gccForLibs; solib = gccForLibs_solib; }
else if givenLibcxx then
{ kind = "libc++"; lib = libcxx; }
{ 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++"; lib = cc_solib; }
{ kind = "libstdc++"; package = cc; solib = cc_solib; }
;

emacsBufferSetup = pkgs: ''
Expand Down Expand Up @@ -590,7 +593,7 @@ stdenv.mkDerivation {
echo "$ccLDFlags" >> $out/nix-support/cc-ldflags
echo "$ccCFlags" >> $out/nix-support/cc-cflags
'' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) ''
echo " -L${lib.getLib libcxx}/lib" >> $out/nix-support/cc-ldflags
echo " -L${libcxx_solib}" >> $out/nix-support/cc-ldflags
''

##
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/cuda-modules/backend-stdenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ 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.lib.version;
-> lib.versionAtLeast cxxStdlib.version stdenv.cc.cxxStdlib.package.version;

lib.extendDerivation assertCondition passthruExtra cudaStdenv

0 comments on commit 8eda4c3

Please sign in to comment.