-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cc-wrapper: expose a single, consistent libcxx #282221
Conversation
This hopefully-obviously-correct commit will allow to change libcxx (see next commit) since it is no longer referenced.
Because the previous commit eliminated all uses of `libcxx` within `cc-wrapper/default.nix` (except for the binding of `libcxx_args`), this commit -- which adds a new binding for `libcxx` -- should have absolutely no effect.
The previous commit sets `libcxx` equal to `gccForLibs` whenever `useGccForLibs` is `true`. This allows us to eliminate all uses of `gccForLibs`.
If `useGccForLibs==true` then `libcxx` is equal to `gccForLibs`, so we can replace `gccForLibs` with `libcxx` inside of any `if useGccForLibs` block.
libcxx = | ||
if libcxx_args != null | ||
then libcxx_args | ||
else if useGccForLibs | ||
then lib.getLib gccForLibs | ||
else null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libcxx
has a connotation with the specific implementation; I think @rrbutani's naming was good: cxxStdlib
@@ -55,6 +55,26 @@ | |||
, includeFortifyHeaders ? null | |||
}: | |||
|
|||
let libcxx_args = libcxx; in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the sequence of let
-expressions one could also add @args
after the lambda's formal parameters, and then define libcxx = if args.libcxx != null then args.libcxx else ...
. Can't say which one is less "wacky". I've seen (and committed) both in nixpkgs
@@ -112,6 +112,13 @@ let | |||
gccForLibs_solib = getLib gccForLibs | |||
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; | |||
|
|||
libcxx = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just move this into the default expression of libcxx
in the args set? Or does something explicitly pass libcxx = null
?
@@ -451,7 +449,7 @@ stdenv.mkDerivation { | |||
'' | |||
+ optionalString useGccForLibs '' | |||
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags | |||
echo "-L${gccForLibs_solib}/lib" >> $out/nix-support/cc-ldflags | |||
echo "-L${libcxx_solib}/lib" >> $out/nix-support/cc-ldflags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be the following, right?
echo "-L${libcxx_solib}${optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"}/lib" >> $out/nix-support/cc-ldflags
@@ -11752,7 +11752,7 @@ with pkgs; | |||
boost = boost179; | |||
libclang = llvmPackages_15.libclang; | |||
clang = | |||
if stdenv.cc.libcxx != null | |||
if stdenv.cc.isClang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdenv.cc.libcxx.pname
should be checked. Not all clang
based stdenv
s use libcxx which would be the case in the else
condition then…
Description of changes
This PR attempts to expose a single consistent
stdenv.cc.passthru.libcxx
attribute from which downstream packages (like CUDA) can determine whatever they need to determine about the C++ standard library in use.Best reviewed one commit at a time; some of the commits are straightforward search-and-replace.
The following PR (which must go to
staging
) may be needed in order to ensure that${lib.getLib stdenv.cc.cc}/lib
contains the C++ libraries regardless of which compiler is being used: