diff options
author | 2017-02-10 18:40:30 +0000 | |
---|---|---|
committer | 2017-02-13 11:31:16 +0000 | |
commit | aa1d31da27793d4c29bfa4dec12d1ae9ab20426b (patch) | |
tree | 39912345a96539768e37d0386a79750eb80b87d6 /src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java | |
parent | 0eaff4437cf23da52983a659456e707d6fd372e3 (diff) |
Blaze/bazel modifications to command line flags used when dead-stripping.
- Passing -g to the compiler is no longer required.
- Instead of detecting test rules, detect "-bundle" in the command line.
- In that case, pass "-x", not "-S", to strip.
- Do not inhibit dead-code stripping for tests.
RELNOTES:
Modifications to command line flags used for dead-stripping.
--
PiperOrigin-RevId: 147171780
MOS_MIGRATED_REVID=147171780
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java index b22a7ec94c..3c0659c094 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/LegacyCompilationSupport.java @@ -60,7 +60,6 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; -import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions.AppleBitcodeMode; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.AppleToolchain; @@ -337,11 +336,6 @@ public class LegacyCompilationSupport extends CompilationSupport { otherFlags, isCPlusPlusSource); - // The linker needs full debug symbol information to perform binary dead-code stripping. - if (objcConfiguration.shouldStripBinary()) { - commandLine.add("-g"); - } - if (collectCodeCoverage) { if (buildConfiguration.isLLVMCoverageMapFormatEnabled()) { commandLine.add(CLANG_LLVM_COVERAGE_FLAGS); @@ -671,10 +665,14 @@ public class LegacyCompilationSupport extends CompilationSupport { return this; } - private boolean isDynamicLib(CommandLine commandLine) { + private static boolean isDynamicLib(CommandLine commandLine) { return Iterables.contains(commandLine.arguments(), "-dynamiclib"); } + private static boolean isBundle(CommandLine commandLine) { + return Iterables.contains(commandLine.arguments(), "-bundle"); + } + private void registerLinkAction( ObjcProvider objcProvider, ExtraLinkArgs extraLinkArgs, @@ -723,12 +721,9 @@ public class LegacyCompilationSupport extends CompilationSupport { if (objcConfiguration.shouldStripBinary()) { final Iterable<String> stripArgs; - if (TargetUtils.isTestRule(ruleContext.getRule())) { - // For test targets, only debug symbols are stripped off, since /usr/bin/strip is not able - // to strip off all symbols in XCTest bundle. - stripArgs = ImmutableList.of("-S"); - } else if (isDynamicLib(commandLine)) { - // For dynamic libs must pass "-x" to strip only local symbols. + // For dynamic libraries and bundles the -x flag must be passed + // to the strip command so that only local symbols are stripped. + if (isDynamicLib(commandLine) || isBundle(commandLine)) { stripArgs = ImmutableList.of("-x"); } else { stripArgs = ImmutableList.<String>of(); @@ -780,10 +775,7 @@ public class LegacyCompilationSupport extends CompilationSupport { commandLine.add(CLANG); } - // Do not perform code stripping on tests because XCTest binary is linked not as an executable - // but as a bundle without any entry point. - boolean isTestTarget = TargetUtils.isTestRule(ruleContext.getRule()); - if (objcConfiguration.shouldStripBinary() && !isTestTarget) { + if (objcConfiguration.shouldStripBinary()) { commandLine.add("-dead_strip").add("-no_dead_strip_inits_and_terms"); } |