Preserve linker arguments across response files - #3350
Open
karim-alweheshy wants to merge 3 commits into
Open
karim-alweheshy wants to merge 3 commits into
karim-alweheshy wants to merge 3 commits into
Conversation
Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
karim-alweheshy
marked this pull request as ready for review
September 23, 2026 15:57
Contributor
Comment on lines
+126
to
+148
| if option in _WL_POSITIONAL_PATH_OPTS and option != "-filelist": | ||
| # Section arguments are metadata/content, not positional libraries. | ||
| for _ in range(max(_WL_POSITIONAL_PATH_OPTS[option])): | ||
| if driver_wrappers and end < len(linkopts) and linkopts[end] == "-Xlinker": | ||
| end += 1 | ||
| end = min(end + 1, len(linkopts)) | ||
| elif option in _SPLIT_PATH_OPTS | _SPLIT_NON_PATH_OPTS: | ||
| value_index = end | ||
| if driver_wrappers and value_index < len(linkopts) and linkopts[value_index] == "-Xlinker": | ||
| value_index += 1 | ||
| if value_index < len(linkopts): | ||
| end = value_index + 1 | ||
| if (option in _LIBRARY_INPUT_OPTS and | ||
| linkopts[value_index] in generated_product_paths): | ||
| index = end | ||
| continue | ||
| elif option in generated_product_paths: | ||
| index = end | ||
| continue | ||
|
|
||
| result.extend(linkopts[index:end]) | ||
| index = end | ||
| return result |
Contributor
There was a problem hiding this comment.
This just reads bad. I get what it's doing, generally, but I feel it could be organized better or have way more comments.
Contributor
Author
There was a problem hiding this comment.
Added comments in 60339e7 around the option categories and removal state machine: which operands stay grouped, when -Xlinker wrappers travel with a removed binding, and why unmatched operands remain ordered. This is comments-only; the AST and representative outputs are unchanged, and all 13 Python tests pass. Does that address the organization concern, or is there a section you would prefer split up?
Comment on lines
+201
to
+205
| # This is a Clang response file, not a shell command. Quote the whole | ||
| # argument and escape response syntax. Double quotes also allow apostrophes | ||
| # introduced later by expansion of PROJECT_DIR or another build setting. | ||
| if any(character in opt for character in " \t\n\r'\"\\") or "$(" in opt: | ||
| return '"' + opt.replace("\\", "\\\\").replace('"', '\\"') + '"' |
Contributor
There was a problem hiding this comment.
This is interesting.
Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
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
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.
Summary
Fix existing Bazel-to-Xcode linker argument translation without introducing a
new Preview mode or changing library-path resolution.
@rpath,@loader_path, and@executable_path.without losing apostrophes, quotes, backslashes or whitespace.
Based on branch
preview-stack-01-linker-flags. This correction is usablewithout any later Preview changes. Library-group removal and Preview-specific
path/runtime handling are intentionally excluded.
Validation
implementation, reproducing dropped arguments, redirect handling and quoting
errors. The existing bundle-flag regression remains covered.
targets reuse cached results.
git diff --checkpass.argument files and an archive path containing spaces and an apostrophe.
The parent fails this combined parsing/quoting case; this candidate passes.
Testing
Run
bazel test //tools/params_processors:link_params_processor_testsandbazel test //.... These checks validate argument translation and ordinarygenerator regressions; they do not claim Preview Canvas rendering.