-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(cc): move user provided -isystem
paths to front of command
#24353
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
base: master
Are you sure you want to change the base?
Conversation
This doesn't seem quite correct; with this change, C flags on modules will no longer be able to override any default flags that we add in |
That's right - those are at the end on purpose so they can override everything else. The proper fix is to adjust the parsing in the CLI to account for isystem args without piggybacking on the general last resort overriding flag set. |
I think I understand! I believe I saw that some flags are parsed out earlier and are pulled out of cc_argv. That makes sense and is a fair concern. Let me spend some time reworking this change and I'll mark it as ready for review again. Thanks for the super quick feedback! I appreciate it! Side Note: I'd really like to add a test for this as well, originally I wanted to perform a test call to zig cc to ensure that the right header is included, then when I couldn't find a good way to do that I tried just testing Compilation.addCCArgs() but it ended up being a ton of code to get a fake |
Putting a test somewhere in |
3746be5
to
8979dab
Compare
zig cc
args to front of command-isystem
paths to front of command
8979dab
to
f3f0602
Compare
Problem: Currently if you pass a `-isystem` argument to `zig cc`, the include path will be searched after all of the libc, libcpp, and native system paths. However if you run the same command against `clang` and `gcc` you'll see that any user provided `-isystem` paths are at the very front. Solution: Push all user provided arguments to the arg list at the start of `addCCArgs()`. This makes it so that any compiler arguments that rely on the order of arguments passed will prioritize the user provided values first. Fixes: ziglang#24243
f3f0602
to
d9e277c
Compare
Hey @alexrp, so I fixed this by just pulling out the Let me know what you think. Part of me was wondering if I should pull this out in Let me know if I should tweak anything else. Also, I added a unit test against |
Problem: Currently if you pass a
-isystem
argument tozig cc
, the include path will be searched after all of the libc, libcpp, and native system paths. However if you run the same command againstclang
andgcc
you'll see that any user provided-isystem
paths are at the very front.Solution: Pull out user provided
-isystem
frommod.cc_argv
andcomp.global_cc_argv
at the start ofaddCCArgs()
, append these paths as-isystem
args just before we append the native system paths. Finally we append the rest of the cc args in the same place.Fixes: #24243