aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar plf <plf@google.com>2018-02-02 10:44:38 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-02 10:46:48 -0800
commitb15710322fb964d087d9676fe01f8c824ab37dc3 (patch)
treebdab8ea056acb57497b8597817e71b6c9d145237 /src/main/java/com/google/devtools/build/lib/rules
parente68c28939f76182d0a365a6db2673ab90877ddf8 (diff)
C++: Stops generating DWO files when PER_OBJECT_DEBUG_INFO feature is not enabled.
RELNOTES:none PiperOrigin-RevId: 184303490
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java7
4 files changed, 36 insertions, 16 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 7b549540a4..7d2aec8624 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
@@ -635,13 +635,19 @@ public final class CcCommon {
? CppRuleClasses.DYNAMIC_LINK_MSVCRT_DEBUG
: CppRuleClasses.DYNAMIC_LINK_MSVCRT_NO_DEBUG);
}
- for (String feature :
- Iterables.concat(
- ImmutableSet.of(
- toolchain.getCompilationMode().toString(), getHostOrNonHostFeature(ruleContext)),
- DEFAULT_FEATURES,
- toolchain.getFeatures().getDefaultFeaturesAndActionConfigs(),
- ruleContext.getFeatures())) {
+ ImmutableList.Builder<String> allFeatures =
+ new ImmutableList.Builder<String>()
+ .addAll(
+ ImmutableSet.of(
+ toolchain.getCompilationMode().toString(),
+ getHostOrNonHostFeature(ruleContext)))
+ .addAll(DEFAULT_FEATURES)
+ .addAll(toolchain.getFeatures().getDefaultFeaturesAndActionConfigs())
+ .addAll(ruleContext.getFeatures());
+ if (CppHelper.useFission(ruleContext.getFragment(CppConfiguration.class), toolchain)) {
+ allFeatures.add(CppRuleClasses.PER_OBJECT_DEBUG_INFO);
+ }
+ for (String feature : allFeatures.build()) {
if (!allUnsupportedFeatures.contains(feature)) {
allRequestedFeaturesBuilder.add(feature);
}
@@ -650,10 +656,6 @@ public final class CcCommon {
allRequestedFeaturesBuilder.addAll(DEFAULT_ACTION_CONFIGS);
- if (CppHelper.useFission(ruleContext.getFragment(CppConfiguration.class), toolchain)) {
- allRequestedFeaturesBuilder.add(CppRuleClasses.PER_OBJECT_DEBUG_INFO);
- }
-
try {
FeatureConfiguration configuration =
toolchain.getFeatures().getFeatureConfiguration(allRequestedFeaturesBuilder.build());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index dd66496263..c9f96cfca0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -1105,4 +1105,16 @@ public class CppHelper {
public static boolean useFission(CppConfiguration config, CcToolchainProvider toolchain) {
return config.fissionIsActiveForCurrentCompilationMode() && toolchain.supportsFission();
}
+
+ /**
+ * Returns true if Fission and PER_OBJECT_DEBUG_INFO are specified and supported by the CROSSTOOL
+ * for the build implied by the given configuration, toolchain and feature configuration.
+ */
+ public static boolean shouldCreatePerObjectDebugInfo(
+ CppConfiguration config,
+ CcToolchainProvider toolchain,
+ FeatureConfiguration featureConfiguration) {
+ return useFission(config, toolchain)
+ && featureConfiguration.isEnabled(CppRuleClasses.PER_OBJECT_DEBUG_INFO);
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index ea3e92b70a..731ac97e16 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -569,7 +569,8 @@ public class CppLinkActionBuilder {
toolchain,
fdoSupport,
usePicForLtoBackendActions,
- CppHelper.useFission(cppConfiguration, toolchain),
+ CppHelper.shouldCreatePerObjectDebugInfo(
+ cppConfiguration, toolchain, featureConfiguration),
argv)
: new LtoBackendArtifacts(
ltoOutputRootPrefix,
@@ -582,7 +583,8 @@ public class CppLinkActionBuilder {
toolchain,
fdoSupport,
usePicForLtoBackendActions,
- CppHelper.useFission(cppConfiguration, toolchain),
+ CppHelper.shouldCreatePerObjectDebugInfo(
+ cppConfiguration, toolchain, featureConfiguration),
argv);
return ltoArtifact;
}
@@ -1646,7 +1648,8 @@ public class CppLinkActionBuilder {
}
if (getLinkType().staticness().equals(Staticness.DYNAMIC)
- && CppHelper.useFission(cppConfiguration, toolchain)) {
+ && CppHelper.shouldCreatePerObjectDebugInfo(
+ cppConfiguration, toolchain, featureConfiguration)) {
buildVariables.addStringVariable(IS_USING_FISSION_VARIABLE, "");
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
index aa36ab6058..7691c2e770 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
@@ -791,7 +791,8 @@ public final class CppModel {
// The source action does not generate dwo when it has bitcode
// output (since it isn't generating a native object with debug
// info). In that case the LtoBackendAction will generate the dwo.
- /* generateDwo= */ CppHelper.useFission(cppConfiguration, ccToolchain)
+ CppHelper.shouldCreatePerObjectDebugInfo(
+ cppConfiguration, ccToolchain, featureConfiguration)
&& !bitcodeOutput,
isGenerateDotdFile(sourceArtifact));
break;
@@ -898,7 +899,9 @@ public final class CppModel {
? CppHelper.getCompileOutputArtifact(ruleContext, gcnoFileName, configuration)
: null;
- boolean generateDwo = CppHelper.useFission(cppConfiguration, ccToolchain);
+ boolean generateDwo =
+ CppHelper.shouldCreatePerObjectDebugInfo(
+ cppConfiguration, ccToolchain, featureConfiguration);
Artifact dwoFile = generateDwo ? getDwoFile(builder.getOutputFile()) : null;
// TODO(tejohnson): Add support for ThinLTO if needed.
boolean bitcodeOutput =