diff options
author | Googler <noreply@google.com> | 2018-03-15 10:01:42 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-15 10:03:10 -0700 |
commit | 4bf49ca0d1065ac57f5d485b635a217d2629dd14 (patch) | |
tree | 54955ee52dde211cae31e003c12868476f5e44a2 /src/main/java/com/google/devtools/build | |
parent | a8082fce423ee933bda3173c8b32a8dad1e3f003 (diff) |
Allow optimization related features to be ignored when unsupported as opposed to reporting errors
PiperOrigin-RevId: 189201637
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java | 49 |
1 files changed, 26 insertions, 23 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 b69bd74300..b25dc7fc85 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 @@ -698,6 +698,7 @@ public final class CcCommon { CcToolchainProvider toolchain) { ImmutableSet.Builder<String> unsupportedFeaturesBuilder = ImmutableSet.builder(); unsupportedFeaturesBuilder.addAll(unsupportedFeatures); + unsupportedFeaturesBuilder.addAll(ruleContext.getDisabledFeatures()); if (!toolchain.supportsHeaderParsing()) { // TODO(bazel-team): Remove once supports_header_parsing has been removed from the // cc_toolchain rule. @@ -726,52 +727,54 @@ public final class CcCommon { : CppRuleClasses.DYNAMIC_LINK_MSVCRT_NO_DEBUG); } + 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); + } + CppConfiguration cppConfiguration = toolchain.getCppConfiguration(); - allRequestedFeaturesBuilder.addAll(getCoverageFeatures(ruleContext)); + allFeatures.addAll(getCoverageFeatures(ruleContext)); if (cppConfiguration.getFdoInstrument() != null - && !ruleContext.getDisabledFeatures().contains(CppRuleClasses.FDO_INSTRUMENT)) { - allRequestedFeaturesBuilder.add(CppRuleClasses.FDO_INSTRUMENT); + && !allUnsupportedFeatures.contains(CppRuleClasses.FDO_INSTRUMENT)) { + allFeatures.add(CppRuleClasses.FDO_INSTRUMENT); } FdoMode fdoMode = toolchain.getFdoMode(); boolean isFdo = fdoMode != FdoMode.OFF && toolchain.getCompilationMode() == CompilationMode.OPT; if (isFdo && fdoMode != FdoMode.AUTO_FDO - && !ruleContext.getDisabledFeatures().contains(CppRuleClasses.FDO_OPTIMIZE)) { - allRequestedFeaturesBuilder.add(CppRuleClasses.FDO_OPTIMIZE); + && !allUnsupportedFeatures.contains(CppRuleClasses.FDO_OPTIMIZE)) { + allFeatures.add(CppRuleClasses.FDO_OPTIMIZE); } if (isFdo && fdoMode == FdoMode.AUTO_FDO) { - allRequestedFeaturesBuilder.add(CppRuleClasses.AUTOFDO); + allFeatures.add(CppRuleClasses.AUTOFDO); // For LLVM, support implicit enabling of ThinLTO for AFDO unless it has been // explicitly disabled. - if (toolchain.isLLVMCompiler() - && !ruleContext.getDisabledFeatures().contains(CppRuleClasses.THIN_LTO)) { - allRequestedFeaturesBuilder.add(CppRuleClasses.ENABLE_AFDO_THINLTO); + if (toolchain.isLLVMCompiler() && !allUnsupportedFeatures.contains(CppRuleClasses.THIN_LTO)) { + allFeatures.add(CppRuleClasses.ENABLE_AFDO_THINLTO); } } if (cppConfiguration.isLipoOptimizationOrInstrumentation()) { // Map LIPO to ThinLTO for LLVM builds. if (toolchain.isLLVMCompiler() && fdoMode != FdoMode.OFF) { - allRequestedFeaturesBuilder.add(CppRuleClasses.THIN_LTO); + if (!allUnsupportedFeatures.contains(CppRuleClasses.THIN_LTO)) { + allFeatures.add(CppRuleClasses.THIN_LTO); + } } else { - allRequestedFeaturesBuilder.add(CppRuleClasses.LIPO); + allFeatures.add(CppRuleClasses.LIPO); } } - 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); |