-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
does not pass -stdlib=libc++
as part of cxxflags
#191152
Comments
@rrbutani Could you please file the PR? Thank you! |
Looking into this again today; it seems like #151879 was actually a symptom of this issue (
Both removing As noted in nixpkgs/pkgs/build-support/cc-wrapper/default.nix Lines 312 to 325 in d23c0da
#151879 was fixed by #153963 which went the route of patching clang to add Unfortunately #153963 did have the side-effect of inadvertently breaking the
I think the bottom line is that we've got a matrix of toolchains and use cases we want to support ( Also worth noting is that as of this writing LLVM 15 does not include the fix in #153963 though it probably should; I was mistaken and #151879 is observable with I think that:
Ultimately Apologies, this turned into a bit of a rant; I'll open a separate issue/PR for this later and try to figure out whether ^ is practical. |
The Bug
Currently
cc-wrapper
does add-stdlib=libc++
tolibcxx-ldflags
but not tolibcxx-cxxflags
.This leads to
clang
appending gcclibstdc++
header search directories to the search path which in turn breakslibc++
headers (#include_next <...>
no longer finds libc headers, as intended, but now findslibstdc++
headers).To Reproduce
nix-shell -p llvmPackages_14.libcxxStdenv.cc --run "echo '#include <string>' | clang++ -c -xc++ -" --pure
^ results in errors that look like this:
Click to expand.
The Fix
Passing in
--std=libc++
inhibitsclang
from adding the gcclibstdc++
header directories to the search path and fixes this error:nix-shell -p llvmPackages_14.libcxxStdenv.cc --run "echo '#include <string>' | clang++ -c -xc++ - --stdlib=libc++" --pure
Running with
-v
lets us compare the list of search directories:clang++ -c -xc++ - -v
:clang++ -c -xc++ - --stdlib=libc++ -v
:This (i.e. adding
echo "-stdlib=libc++" >> $out/nix-support/libcxx-cxxflags
here) seems like an uncontroversial change to me but I thought I'd open an issue about this first just in case I'm missing something obvious or just not using the wrapper compiler correctly.Notify maintainers
CODEOWNERS
forcc-wrapper
points to @Ericson2314; apologies if this is incorrect.Metadata
The text was updated successfully, but these errors were encountered: