From b422719f35b1ae5ed5f7f83d05cd778e9c58d793 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 25 Oct 2022 12:37:20 -0700 Subject: [PATCH] Make constraint_setting / constraint_value non_configurable. The concept of allowing what is fundamentally a constant to vary by target we are building for is too much to reason about, let along get the code correct. PiperOrigin-RevId: 483748098 Change-Id: I966b7d21ad8d38de9867c870a0669e2123063809 --- .../build/lib/rules/platform/ConstraintSettingRule.java | 4 +++- .../build/lib/rules/platform/ConstraintValueRule.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java index fe47d8f1974af1..7449ece8e92c3b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java @@ -43,7 +43,9 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) constraint list (such as for a config_setting) that requires a particular value for that setting. */ - .add(attr(DEFAULT_CONSTRAINT_VALUE_ATTR, BuildType.NODEP_LABEL)) + .add( + attr(DEFAULT_CONSTRAINT_VALUE_ATTR, BuildType.NODEP_LABEL) + .nonconfigurable("constants must be consistent across configurations")) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java index 1a34bff1929781..b716a0aa86bbf0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java @@ -42,7 +42,8 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) .mandatory() .allowedRuleClasses(ConstraintSettingRule.RULE_NAME) .allowedFileTypes(FileTypeSet.NO_FILE) - .mandatoryProviders(ConstraintSettingInfo.PROVIDER.id())) + .mandatoryProviders(ConstraintSettingInfo.PROVIDER.id()) + .nonconfigurable("constants must be consistent across configurations")) .build(); }