Skip to content

Preserve linker arguments across response files - #3350

Open
karim-alweheshy wants to merge 5 commits into
mainfrom
preview-stack-link-arguments
Open

karim-alweheshy wants to merge 5 commits into
mainfrom
preview-stack-link-arguments

Conversation

@karim-alweheshy

@karim-alweheshy karim-alweheshy commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Xcode needs linker arguments preserved with their original boundaries; the current translator can lose information across Bazel response-file chunks.

What and how

Preserve chunks, expand first-level response-file redirects, and remove selected library bindings as complete option groups, including -Xlinker pairs.

Boundary

This fixes the existing Bazel-to-Xcode translation path. It does not enable native Preview mode or change library-path resolution.

Validation

Regression tests cover chunk handling, redirects, quoting, and grouped-option removal. Tests were not rerun for this description update.

Testing

Run bazel test //tools/params_processors:link_params_processor_tests. No Xcode Preview Canvas render is claimed.

Karim Alweheshy added 2 commits September 23, 2026 12:00
Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
@karim-alweheshy
karim-alweheshy marked this pull request as ready for review September 23, 2026 15:57
@karim-alweheshy
karim-alweheshy requested a review from a team as a code owner September 23, 2026 15:57
Signed-off-by: Karim Alweheshy <karim.alweheshy@gmail.com>
@0xLucasMarcal

Copy link
Copy Markdown
Contributor

cc @brentleyjones

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just reads bad. I get what it's doing, generally, but I feel it could be organized better or have way more comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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('"', '\\"') + '"'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting.

Comment thread tools/params_processors/link_params_processor.py Outdated
Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
@karim-alweheshy
karim-alweheshy requested review from a team and brentleyjones October 1, 2026 17:59
Base automatically changed from preview-stack-01-linker-flags to main October 6, 2026 22:33
Signed-off-by: Karim Alweheshy <karim.alweheshy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants