Skip to content

Commit f0d8cc7

Browse files
cpsauerkatre
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 ff9919b commit f0d8cc7

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
@@ -1074,6 +1074,9 @@ private StrippingType getStrippingType(ExtraLinkArgs extraLinkArgs) {
10741074
if (Iterables.contains(extraLinkArgs, "-dynamiclib")) {
10751075
return StrippingType.DYNAMIC_LIB;
10761076
}
1077+
if (Iterables.contains(extraLinkArgs, "-bundle")) {
1078+
return StrippingType.LOADABLE_BUNDLE;
1079+
}
10771080
if (Iterables.contains(extraLinkArgs, "-kext")) {
10781081
return StrippingType.KERNEL_EXTENSION;
10791082
}
@@ -1544,6 +1547,7 @@ private static CommandLine symbolStripCommandLine(
15441547
private enum StrippingType {
15451548
DEFAULT,
15461549
DYNAMIC_LIB,
1550+
LOADABLE_BUNDLE,
15471551
KERNEL_EXTENSION
15481552
}
15491553

@@ -1555,8 +1559,9 @@ private void registerBinaryStripAction(Artifact binaryToLink, StrippingType stri
15551559
final ImmutableList<String> stripArgs;
15561560
switch (strippingType) {
15571561
case DYNAMIC_LIB:
1562+
case LOADABLE_BUNDLE:
15581563
case KERNEL_EXTENSION:
1559-
// For dylibs and kexts, must strip only local symbols.
1564+
// For dylibs, loadable bundles, and kexts, must strip only local symbols.
15601565
stripArgs = ImmutableList.of("-x");
15611566
break;
15621567
case DEFAULT:

0 commit comments

Comments
 (0)