Skip to content
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

Closed
wants to merge 18 commits into from
Closed

cc-wrapper: expose a single, consistent libcxx #282221

wants to merge 18 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 20, 2024

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:

Adam Joseph added 18 commits January 19, 2024 21:47
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.
@ghost ghost marked this pull request as ready for review January 20, 2024 08:46
@ofborg ofborg bot added the 10.rebuild-linux-stdenv This PR causes stdenv to rebuild label Jan 20, 2024
Comment on lines +70 to +75
libcxx =
if libcxx_args != null
then libcxx_args
else if useGccForLibs
then lib.getLib gccForLibs
else null;
Copy link
Contributor

@SomeoneSerge SomeoneSerge Jan 20, 2024

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
Copy link
Contributor

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 =
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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 stdenvs use libcxx which would be the case in the else condition then…

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants