-
-
Notifications
You must be signed in to change notification settings - Fork 241
Support response files with quoted args #479
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
Open
faximan
wants to merge
2
commits into
bazel-contrib:master
Choose a base branch
from
faximan:faximan/fix-quoting
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fmeum
approved these changes
Apr 9, 2025
CI is red |
This was because some args are like |
dfreese
added a commit
to dfreese/toolchains_llvm
that referenced
this pull request
Apr 9, 2025
The cc_wrapper.sh scripts inspects response files and sanitizes each line within them. How the logic is structured currently causes all of these arguments to the be directly used later in the script. This can run into argument overflows. It can also run into problems where quoting in response files and from args is treated differently. This addresses some of the comments in bazel-contrib#430, namely cleaning up files and not overwriting the input files. I have not tried to apply a threshold here as that is best left up to the tooling that previously decided to use response files, which can cause difficult to debug changes in behavior. This conflicts with bazel-contrib#479, but is trying to address the same underlying problem of quoted arguments in response files as the result of golang's link actions. Fixes bazel-contrib#421
fmeum
pushed a commit
that referenced
this pull request
Apr 10, 2025
The cc_wrapper.sh scripts inspects response files and sanitizes each line within them. How the logic is structured currently causes all of these arguments to the be directly used later in the script. This can run into argument overflows. It can also run into problems where quoting in response files and from args is treated differently. This addresses some of the comments in #430, namely cleaning up files and not overwriting the input files. I have not tried to apply a threshold here as that is best left up to the tooling that previously decided to use response files, which can cause difficult to debug changes in behavior. This conflicts with #479, but is trying to address the same underlying problem of quoted arguments in response files as the result of golang's link actions. Fixes #421
@faximan Could you rebase and resolve the conflict? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#245 introduced a regression where clang response files were read and expanded into args on the command line.
This was a regression because response files support quoted args:
but
cc_wrapper.sh
will expand this toThis is not just a theoretical concern: golang (which is using a c++ linker for its cgo integration) is explicitly quoting its strings in the response files: https://github.com/golang/go/blob/ecc06f0db79193a4fe16138148c7eb26d9af96f1/src/cmd/link/internal/ld/lib.go#L2123-L2124
This PR solves this by processing what's inside the quotes instead of the string as a whole. As a bonus, this will also support multiple (quoted or unquoted) args on a single line, which is something clang supports but toolchains_llvm does not. The fix is inspired by https://stackoverflow.com/a/17346794 but modified to support args starting with
$
(need to be passed through).Note that another related fix is #430, which passes through the response files to clang. That PR would also be great to support very long arg lists, but we still need this PR to properly call
sanitize_option
for quoted args.