aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar rosica <rosica@google.com>2018-05-16 06:35:25 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-16 06:37:45 -0700
commitd0561c72ad15109ce4784aa26973e8c721c72591 (patch)
treeb8e4912e6d5015a970c799584317e83fcad4a459 /src/main/java
parent7092ed324137f03fcd34856bdb0595a1bdec3069 (diff)
Make inclusion of the zipper executable in CcToolchain depend solely on whether FDO optimization is used (--fdo_optimize or --fdo_profile)
As part of the work of removing usage of c++ toolchain from CppConfiguration, CppConfiguration#isLLVMCompiler method needs to be removed. Currently, CppConfiguration#shouldIncludeZipperInToolchain (former CppConfiguration#isLLVMOptimizedFdo) method uses the CppConfiguration#isLLVMCompiler method to determine whether the compiler is LLVM and conditionally includes the zipper if the compiler is LLVM and FDO optimization is in place. Instead of rerouting the information on the compiler and FDO profile through FeatureFlagInfo, we make the inclusion of the zipper executable depend only on usage of FDO optimization. PiperOrigin-RevId: 196819907
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java15
2 files changed, 11 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
index 563713933c..29831acc1c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java
@@ -67,6 +67,16 @@ public final class CcToolchainRule implements RuleDefinition {
null,
(rule, attributes, cppConfig) -> cppConfig.getFdoProfileLabel());
+ /**
+ * Returns true if zipper should be loaded. We load the zipper executable if FDO optimization is
+ * enabled through --fdo_optimize or --fdo_profile
+ */
+ private static boolean shouldIncludeZipperInToolchain(CppConfiguration cppConfiguration) {
+ return cppConfiguration.getFdoOptimizeLabel() != null
+ || cppConfiguration.getFdoProfileLabel() != null
+ || cppConfiguration.getFdoPath() != null;
+ }
+
@Override
public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
final Label zipper = env.getToolsLabel("//tools/zip:zipper");
@@ -137,9 +147,8 @@ public final class CcToolchainRule implements RuleDefinition {
LabelLateBoundDefault.fromTargetConfiguration(
CppConfiguration.class,
null,
- // TODO(b/69547565): Remove call to shouldIncludeZipperInToolchain
(rule, attributes, cppConfig) ->
- cppConfig.shouldIncludeZipperInToolchain() ? zipper : null)))
+ shouldIncludeZipperInToolchain(cppConfig) ? zipper : null)))
.add(attr(":libc_top", LABEL).value(LIBC_TOP))
.add(attr(":fdo_optimize", LABEL).singleArtifact().value(FDO_OPTIMIZE_LABEL))
.add(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
index 6f262410c2..4761c2b6d4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -890,21 +890,6 @@ public final class CppConfiguration extends BuildConfiguration.Fragment {
return cppToolchainInfo.isLLVMCompiler();
}
- /**
- * Returns true if LLVM FDO Optimization should be applied for this configuration.
- *
- * <p>Deprecated: Use {@link CcToolchain#isLLVMOptimizedFdo(boolean, PathFragment)}
- */
- // TODO(b/64384912): Remove in favor of overload with isLLVMCompiler.
- @Deprecated
- public boolean shouldIncludeZipperInToolchain() {
- return (cppOptions.getFdoOptimize() != null
- && (CppFileTypes.LLVM_PROFILE.matches(cppOptions.getFdoOptimize())
- || CppFileTypes.LLVM_PROFILE_RAW.matches(cppOptions.getFdoOptimize())
- || (isLLVMCompiler() && cppOptions.getFdoOptimize().endsWith(".zip"))))
- || (cppOptions.getFdoProfileLabel() != null);
- }
-
/** Returns true if LIPO optimization is implied by the flags of this build. */
public boolean lipoOptimizationIsActivated() {
return cppOptions.isLipoOptimization();