cc-wrapper: fix -Bprefix to not confuse lib/libc++.so and bin/c++ #317224
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this commit,
pkgs/build-support/cc-wrapper/add-flags.sh
was using-B@out@/bin
instead of-B@bintools@/bin
to forcecc
to useld-wrapper.sh
when callingld
. That was confusingcc
when asked to print the location of a library precisely namedc++
because-B
prefixes are also used bycc
to find libraries, see https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#index-BIndeed, instead of having
cc --print-file-name c++
failing to find ac++
library and just returning the givenc++
string to let a linker resolve it thereafter, it was finding that@out@/bin/c++
executable, mistaking it for a library and returning its absolute path, forcing the linker to load an executable as a library.Users should likely ask for
libc++.so
instead ofc++
, but that's not what's done,For instance this confusion was breaking with GHC on Darwin:
https://gitlab.haskell.org/ghc/ghc/-/issues/23138#note_567034
It's not clear to me why only the Darwin port of GHC was affected since this
-B
was also injected in the Linux toolchain.And I don't have a Darwin host to test whether this fix is enough to solve the GHC bug mentioned.
But the result of
cc --print-file-name c++
is clearly wrong to motivate this fix:Before this commit:
After this commit:
Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.