Skip to content
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

macOS frameworks: symbol stripping fails #11869

Closed
cpsauer opened this issue Jul 30, 2020 · 3 comments
Closed

macOS frameworks: symbol stripping fails #11869

cpsauer opened this issue Jul 30, 2020 · 3 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: bug

Comments

@cpsauer
Copy link
Contributor

cpsauer commented Jul 30, 2020

Hi wonderful Bazel folks,

It seems something has broken in the stripping of macos_bundle in the past few versions. TL;DR: to fix the issue, I think we should pass a slightly less zealous option to strip (-x)--and maybe fix stripopts.

In more detail:
Trying to build a framework with --compilation_mode=opt leads to
error: symbols referenced by indirect symbol table entries that can't be stripped
Debug builds work fine. iOS frameworks work fine. This worked in Bazel 2.2, but is failing in 3.4.
(You do need to pass --objc_enable_binary_stripping to see the issue, since otherwise Bazel doesn't try to strip objc binaries.)

I'm pretty sure I've seen this issue in Xcode projects a long time ago, when one tries to mistakenly strip "All Symbols" instead of "Non-Global Symbols" (i.e. defaulting to strip instead of strip -x). You can't pass this in through bazel because --strip_opt doesn't seem to work with macos_bundle...but I've confirmed manually that it fixes the issue. Apple does note in the man page for strip that "For dynamic shared libraries, the maximum level of stripping is usually -x (to remove all non-global symbols)."

Thanks so much,
Chris

@aiuto aiuto added z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple untriaged labels Jul 31, 2020
@tetromino tetromino added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Aug 6, 2020
@tetromino
Copy link
Contributor

tetromino commented Aug 6, 2020

@trybka is currently working on a design for better Apple stripping and perhaps can comment.

@susinmotion susinmotion added platform: apple team-Rules-CPP Issues for C++ rules and removed z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple labels Nov 18, 2020
@oquenchil oquenchil added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) labels Nov 19, 2020
@cpsauer
Copy link
Contributor Author

cpsauer commented Apr 1, 2021

@trybka, any thoughts or updates on the iOS stripping situation?

@trybka
Copy link
Contributor

trybka commented Apr 8, 2021

@trybka, any thoughts or updates on the iOS stripping situation?

No thoughts beyond #13123 (comment) and https://github.com/trybka/scraps/blob/master/Apple_Stripping.md

I think your commit to add -x to improve bundles is reasonable, though.

@googlewalt is working on more unification of the C++ and Objc underlying rule support, and I think that will unblock the way to share more of the common idioms (like a strip action which respects stripopt).

katre pushed a commit that referenced this issue Jul 12, 2021
Adds `-x` flag to stripping of macOS loadable bundles.

Loadable bundles--i.e. truly dynamically loadable libraries on macOS--cannot be stripped without this flag, since you'd be trying to strip away the all symbols, including those used for dynamic loading. Doing so results in `error: symbols referenced by indirect symbol table entries that can't be stripped`.

`-x` instead leads to the removal of the unneeded local symbols. As Apple notes in their man page: "For dynamic shared libraries, the maximum level of stripping is usually -x (to remove all non-global symbols)."

This should fix #11869

Closes #13314.

PiperOrigin-RevId: 368841977
katre pushed a commit that referenced this issue Jul 19, 2021
Adds `-x` flag to stripping of macOS loadable bundles.

Loadable bundles--i.e. truly dynamically loadable libraries on macOS--cannot be stripped without this flag, since you'd be trying to strip away the all symbols, including those used for dynamic loading. Doing so results in `error: symbols referenced by indirect symbol table entries that can't be stripped`.

`-x` instead leads to the removal of the unneeded local symbols. As Apple notes in their man page: "For dynamic shared libraries, the maximum level of stripping is usually -x (to remove all non-global symbols)."

This should fix #11869

Closes #13314.

PiperOrigin-RevId: 368841977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants