-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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. |
We’ve had to disable However, I still think that Rambling comment, sorry, but I wanted to get my thoughts out. I’m very much in favour of passing cc @reckenrode who had opinions on this too |
Remove a patch to decrease the divergence from upstream. Motivation is a continuation of trying to reduce the number of clang builds floating around. Wrapper builds are cheap, compiler builds are not. It's expected that this patch can be removed at some point and replaced with some other cc-wrapper logic. This will be a little bit easier with the logic already in the cc-wrapper. Ongoing discussion in NixOS#191152. It would be nice to drop this but we think it's probably needed at least on systems where /usr/include may be available to prevent the possibility of picking up unwanted includes. One potential method for eliminating nostdlibinc in the future is by providing a non-existent -sysroot but that was reverted in NixOS#213185, and remains a can of worms. Signed-off-by: Peter Waller <p@pwaller.net>
Remove a patch to decrease the divergence from upstream. Motivation is a continuation of trying to reduce the number of clang builds floating around. Wrapper builds are cheap, compiler builds are not. It's expected that this patch can be removed at some point and replaced with some other cc-wrapper logic. This will be a little bit easier with the logic already in the cc-wrapper. Ongoing discussion in NixOS#191152. It would be nice to drop this but we think it's probably needed at least on systems where /usr/include may be available to prevent the possibility of picking up unwanted includes. One potential method for eliminating nostdlibinc in the future is by providing a non-existent -sysroot but that was reverted in NixOS#213185, and remains a can of worms. Signed-off-by: Peter Waller <p@pwaller.net>
Remove a patch to decrease the divergence from upstream. Motivation is a continuation of trying to reduce the number of clang builds floating around. Wrapper builds are cheap, compiler builds are not. It's expected that this patch can be removed at some point and replaced with some other cc-wrapper logic. This will be a little bit easier with the logic already in the cc-wrapper. Ongoing discussion in NixOS#191152. It would be nice to drop this but we think it's probably needed at least on systems where /usr/include may be available to prevent the possibility of picking up unwanted includes. One potential method for eliminating nostdlibinc in the future is by providing a non-existent -sysroot but that was reverted in NixOS#213185, and remains a can of worms. Signed-off-by: Peter Waller <p@pwaller.net>
Remove a patch to decrease the divergence from upstream. Motivation is a continuation of trying to reduce the number of clang builds floating around. Wrapper builds are cheap, compiler builds are not. It's expected that this patch can be removed at some point and replaced with some other cc-wrapper logic. This will be a little bit easier with the logic already in the cc-wrapper. Ongoing discussion in NixOS#191152. It would be nice to drop this but we think it's probably needed at least on systems where /usr/include may be available to prevent the possibility of picking up unwanted includes. One potential method for eliminating nostdlibinc in the future is by providing a non-existent -sysroot but that was reverted in NixOS#213185, and remains a can of worms. Signed-off-by: Peter Waller <p@pwaller.net>
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: