Skip to content

Remove selected libraries with complete linker option groups - #3351

Merged
karim-alweheshy merged 2 commits into
preview-stack-link-argumentsfrom
preview-stack-link-groups
Sep 27, 2026
Merged

karim-alweheshy merged 2 commits into
preview-stack-link-argumentsfrom
preview-stack-link-groups

Conversation

@karim-alweheshy

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

Copy link
Copy Markdown
Contributor

Summary

Remove a selected Bazel-built library from Xcode linker arguments together with
its complete option group. Previously, removing only the library could leave
-force_load or -Xlinker to consume the next unrelated argument.

  • Handle direct, -Xlinker-forwarded and -Wl,-grouped library inputs.
  • Match the exact selected product rather than arbitrary path suffixes.
  • Preserve unrelated library bindings, adjacent options, install names and
    section-content operands.

Based on branch preview-stack-link-arguments. This is an independently
useful correction to the existing translator; it does not enable native
Previews, reanchor paths or introduce static-library runtime policy.

Validation

  • Twelve focused Python tests pass, including the seven inherited argument
    tests and five new grouped-removal tests.
  • The unchanged suite produces 20 assertion/subtest failures against the
    parent and passes against this candidate.
  • All 99 root Bazel test targets pass on Bazel 9.2.0 and Xcode 27.0; unchanged
    targets reuse cached results.
  • Repository Buildifier and git diff --check pass.
  • A standalone Apple Clang control fails to link on the parent because of
    dangling forwarded options. This candidate links and runs the native
    replacement implementation together with the retained dependency archive.

Testing

Run bazel test //tools/params_processors:link_params_processor_tests and
bazel test //.... Review the preserved neighboring arguments as well as
the removed library. Preview activation and Canvas validation are outside
this change.

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:58
@karim-alweheshy
karim-alweheshy requested a review from a team as a code owner September 23, 2026 15:58
"-weak_framework",
}

_LIBRARY_INPUT_OPTS = {

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.

[P2] Handle the remaining library-binding options

The new option tables miss three valid library bindings:

  • -Wl,-lazy_library,<selected> becomes a dangling -Wl,-lazy_library. With -framework Foundation next, the linker consumes -framework as the library path and fails.
  • -delay_library and -assert_weak_library are classified as path options but omitted from _LIBRARY_INPUT_OPTS, so their selected archives remain in the output.

I reproduced all three with Apple Clang 21 / Xcode 27. The original linker inputs are accepted. The parent translator removes each complete comma group and the native replacement links successfully; this revision either leaves the dangling option or fails when the Bazel archive being replaced is absent.

Please add these bindings to the appropriate tables and regression tests. All 12 existing focused tests pass, but they do not cover these options.

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.

Fixed in f2e5f98. I added -lazy_library to both the path-option and removable-library-input tables, and added -delay_library and -assert_weak_library to removable library inputs.

Regression coverage exercises plain, -Xlinker, and -Wl, forms and preserves the retained dependency and following framework option. All 13 focused tests pass locally. New-head CI is still running.

Signed-off-by: Karim Alweheshy <karim.alweheshy@reddit.com>
@karim-alweheshy
karim-alweheshy merged commit 8f3a59b into preview-stack-link-arguments Sep 27, 2026
9 checks passed
@karim-alweheshy
karim-alweheshy deleted the preview-stack-link-groups branch September 27, 2026 11:02
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.

2 participants