diff options
author | 2017-04-20 17:11:00 +0200 | |
---|---|---|
committer | 2017-04-24 16:47:12 +0200 | |
commit | 27a136b9bbb4d73b0a343d407b5da9f890175aea (patch) | |
tree | 804af7885233ba62c0097969a3ff6ad44c1708ba | |
parent | e684392afc06a07c4fe6885c9eca7795c35e44c4 (diff) |
Initialize FeatureConfiguration for hip toolchain when building hip
Before, we correctly replaced CppConfiguration with HipCppConfiguration for hip
builds, but we didn't update FeatureConfiguration. As Blaze was not using
action_configs for compile actions, compiler tool was taken from configuration
at the action creation time, not from FeatureConfiguration, so the tool was
correct. Command line flags (some of them) were computed by
FeatureConfiguration, but luckily the toolchains were so similar that it
worked.
In https://github.com/bazelbuild/bazel/commit/e1d692e486a2f838c3c894fd9de693fabd6685ed I tried to use action_configs for compile actions. The result
was that compiler tool was taken from configuration at the CppConfiguration
creation time, that was put into FeatureConfiguration, and that was used in
action creation time. Sadly, the tool in CppConfiguration was different that
the tool in HipCppConfiguration, and b/37315875 was discovered.
This cl also uppdates FeatureConfiguration when HipCppConfiguration is
replaced.
RELNOTES: None.
PiperOrigin-RevId: 153710405
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java | 33 |
1 files changed, 31 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 597e5dd1a8..ea18ab94cb 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 @@ -531,9 +531,10 @@ public final class CcCommon { * * @param ruleContext the context of the rule we want the feature configuration for. * @param ruleSpecificRequestedFeatures features that will be requested, and thus be always - * enabled if the toolchain supports them. + * enabled if the toolchain supports them. * @param ruleSpecificUnsupportedFeatures features that are not supported in the current context. * @param sourceCategory the source category for this build. + * @param toolchain the current toolchain provider * @return the feature configuration for the given {@code ruleContext}. */ public static FeatureConfiguration configureFeatures( @@ -542,6 +543,34 @@ public final class CcCommon { Set<String> ruleSpecificUnsupportedFeatures, SourceCategory sourceCategory, CcToolchainProvider toolchain) { + return configureFeatures( + ruleContext, + ruleSpecificRequestedFeatures, + ruleSpecificUnsupportedFeatures, + sourceCategory, + toolchain, + toolchain.getFeatures()); + } + + /** + * Creates the feature configuration for a given rule. + * + * @param ruleContext the context of the rule we want the feature configuration for. + * @param ruleSpecificRequestedFeatures features that will be requested, and thus be always + * enabled if the toolchain supports them. + * @param ruleSpecificUnsupportedFeatures features that are not supported in the current context. + * @param sourceCategory the source category for this build. + * @param toolchain the current toolchain provider + * @param features CcToolchainFeatures instance to use to get FeatureConfiguration + * @return the feature configuration for the given {@code ruleContext}. + */ + public static FeatureConfiguration configureFeatures( + RuleContext ruleContext, + Set<String> ruleSpecificRequestedFeatures, + Set<String> ruleSpecificUnsupportedFeatures, + SourceCategory sourceCategory, + CcToolchainProvider toolchain, + CcToolchainFeatures features) { ImmutableSet.Builder<String> unsupportedFeaturesBuilder = ImmutableSet.builder(); unsupportedFeaturesBuilder.addAll(ruleSpecificUnsupportedFeatures); if (!toolchain.supportsHeaderParsing()) { @@ -571,7 +600,7 @@ public final class CcCommon { requestedFeatures.addAll(sourceCategory.getActionConfigSet()); FeatureConfiguration configuration = - toolchain.getFeatures().getFeatureConfiguration(requestedFeatures.build()); + features.getFeatureConfiguration(requestedFeatures.build()); for (String feature : unsupportedFeatures) { if (configuration.isEnabled(feature)) { ruleContext.ruleError("The C++ toolchain '" |