aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-05-17 13:07:38 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-17 13:09:00 -0700
commit128c874999eb3f313a992e95d6ab94e557ff7e81 (patch)
tree03dfbb244eb099a28b3f951173ea00ff0d74300f /src/main/java/com/google/devtools/build
parent5649d58296c0c1bc0213c1b92b51934b06ca3605 (diff)
Support for ThinLTO to be enabled implicitly with FDO
Allows for ThinLTO to be enabled once the --features=fdo_implicit_thinlto feature is enabled in the crosstool. Also allows for --features=-thin_lto to override and prevent ThinLTO from being enabled. This is essentially the same as https://github.com/bazelbuild/bazel/commit/8e3afccd8bea45105752ddeb33bde111c556fb8b but for instrumentation FDO instead of AFDO. RELNOTES: None. PiperOrigin-RevId: 197038710
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java9
2 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
index d5f1fba1f8..dade3218a3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java
@@ -834,6 +834,11 @@ public final class CcCommon {
&& fdoMode != FdoMode.AUTO_FDO
&& !allUnsupportedFeatures.contains(CppRuleClasses.FDO_OPTIMIZE)) {
allFeatures.add(CppRuleClasses.FDO_OPTIMIZE);
+ // For LLVM, support implicit enabling of ThinLTO for FDO unless it has been
+ // explicitly disabled.
+ if (toolchain.isLLVMCompiler() && !allUnsupportedFeatures.contains(CppRuleClasses.THIN_LTO)) {
+ allFeatures.add(CppRuleClasses.ENABLE_FDO_THINLTO);
+ }
}
if (isFdo && fdoMode == FdoMode.AUTO_FDO) {
allFeatures.add(CppRuleClasses.AUTOFDO);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
index 2862cbc67e..b15ffb57d2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppRuleClasses.java
@@ -287,12 +287,17 @@ public class CppRuleClasses {
/*
* A string constant for allowing implicit ThinLTO enablement for AFDO.
*/
- public static final java.lang.String AUTOFDO_IMPLICIT_THINLTO = "autofdo_implicit_thinlto";
+ public static final String AUTOFDO_IMPLICIT_THINLTO = "autofdo_implicit_thinlto";
/*
* A string constant for enabling ThinLTO for AFDO implicitly.
*/
- public static final java.lang.String ENABLE_AFDO_THINLTO = "enable_afdo_thinlto";
+ public static final String ENABLE_AFDO_THINLTO = "enable_afdo_thinlto";
+
+ /*
+ * A string constant for enabling ThinLTO for FDO implicitly.
+ */
+ public static final String ENABLE_FDO_THINLTO = "enable_fdo_thinlto";
/**
* A string constant for allowing use of shared LTO backend actions for linkstatic tests building