cc-wrapper: cxxStdlib: expose solib and package separately

This commit is contained in:
Someone Serge 2024-01-10 23:23:05 +00:00
parent 210ce38408
commit 8eda4c36a5
No known key found for this signature in database
GPG key ID: 7B0E3B1390D61DA4
2 changed files with 8 additions and 5 deletions

View file

@ -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
@ -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: ''
@ -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
''
##

View file

@ -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