Skip to content

macOS frameworks: symbol stripping fails #11869

@cpsauer

Description

@cpsauer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)platform: appleteam-Rules-CPPIssues for C++ rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions