Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cc-wrapper: fix -Bprefix to not confuse lib/libc++.so and bin/c++
Before this commit, `pkgs/build-support/cc-wrapper/add-flags.sh` was using `-B@out@/bin` instead of `-B@bintools@/bin` to force `cc` to use `ld-wrapper.sh` when calling `ld`. That was confusing `cc` when asked to print the location of a library precisely named `c++` because `-B` prefixes are also used by `cc` to find libraries, see https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#index-B Indeed, instead of having `cc --print-file-name c++` failing to found a `c++` library and just returning the given `c++` 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. Before this commit: ```console $ nix run -f . stdenv.cc -- --print-file-name c++ /nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/c++ ``` After this commit: ```console $ nix run -f . stdenv.cc -- --print-file-name c++ c++ ``` Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/23138#note_567034 where this behavior was breaking GHC on Darwin. [Confirmed by @414owen](NixOS#317224 (comment)): > This fixed all our haskell builds on Arm64 darwin, which were trying > to link in clang++...
- Loading branch information