Skip to content

Commit 1a0285c

Browse files
cpsauercopybara-github
authored andcommitted
Fix stripping of macOS loadable bundles
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
1 parent 507aeaa commit 1a0285c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,9 @@ private StrippingType getStrippingType(ExtraLinkArgs extraLinkArgs) {
10861086
if (Iterables.contains(extraLinkArgs, "-dynamiclib")) {
10871087
return StrippingType.DYNAMIC_LIB;
10881088
}
1089+
if (Iterables.contains(extraLinkArgs, "-bundle")) {
1090+
return StrippingType.LOADABLE_BUNDLE;
1091+
}
10891092
if (Iterables.contains(extraLinkArgs, "-kext")) {
10901093
return StrippingType.KERNEL_EXTENSION;
10911094
}
@@ -1593,6 +1596,7 @@ private static CommandLine symbolStripCommandLine(
15931596
private enum StrippingType {
15941597
DEFAULT,
15951598
DYNAMIC_LIB,
1599+
LOADABLE_BUNDLE,
15961600
KERNEL_EXTENSION
15971601
}
15981602

@@ -1604,8 +1608,9 @@ private void registerBinaryStripAction(Artifact binaryToLink, StrippingType stri
16041608
final ImmutableList<String> stripArgs;
16051609
switch (strippingType) {
16061610
case DYNAMIC_LIB:
1611+
case LOADABLE_BUNDLE:
16071612
case KERNEL_EXTENSION:
1608-
// For dylibs and kexts, must strip only local symbols.
1613+
// For dylibs, loadable bundles, and kexts, must strip only local symbols.
16091614
stripArgs = ImmutableList.of("-x");
16101615
break;
16111616
case DEFAULT:

0 commit comments

Comments
 (0)