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.
libcxx has a connotation with the specific implementation; I think @rrbutani's naming was good: cxxStdlib
| , includeFortifyHeaders ? null | ||
| }: | ||
|
|
||
| let libcxx_args = libcxx; in |
There was a problem hiding this comment.
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
| gccForLibs_solib = getLib gccForLibs | ||
| + optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; | ||
|
|
||
| libcxx = |
There was a problem hiding this comment.
Can't you just move this into the default expression of libcxx in the args set? Or does something explicitly pass libcxx = null?
| + 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.
This needs to be the following, right?
echo "-L${libcxx_solib}${optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"}/lib" >> $out/nix-support/cc-ldflags
| libclang = llvmPackages_15.libclang; | ||
| clang = | ||
| if stdenv.cc.libcxx != null | ||
| if stdenv.cc.isClang |
There was a problem hiding this comment.
stdenv.cc.libcxx.pname should be checked. Not all clang based stdenvs 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.libcxxattribute 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}/libcontains the C++ libraries regardless of which compiler is being used: