Create --incompatible_enable_late_bound_option_defaults flag
Equivalent to --experimental_use_late_bound_option_defaults, with a name that conforms to the policy for incompatible changes.
RELNOTES: None.
PiperOrigin-RevId: 210714389
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index bbec469..7590d6a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -855,6 +855,23 @@
+ "removal of late bound option defaults.")
public boolean useLateBoundOptionDefaults;
+ @Option(
+ name = "incompatible_enable_late_bound_option_defaults",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS},
+ metadataTags = {
+ OptionMetadataTag.INCOMPATIBLE_CHANGE,
+ OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
+ },
+ help =
+ "When false, Bazel will not allow late bound values read from the CROSSTOOL file "
+ + "to be used in config_settings. The CROSSTOOL field used in this manner is "
+ + "'compiler'. Instead of config_setting(values = {'compiler': 'x'}), "
+ + "config_setting(flag_values = {'@bazel_tools/tools/cpp:compiler': 'x'}) should "
+ + "be used.")
+ public boolean incompatibleEnableLateBoundOptionDefaults;
+
/**
* Converter for --experimental_dynamic_configs.
*/
@@ -1254,7 +1271,11 @@
this.testTimeout = ImmutableMap.copyOf(options.testTimeout);
this.transitiveOptionDetails =
- computeOptionsMap(buildOptions, fragments.values(), options.useLateBoundOptionDefaults);
+ computeOptionsMap(
+ buildOptions,
+ fragments.values(),
+ (options.useLateBoundOptionDefaults
+ && options.incompatibleEnableLateBoundOptionDefaults));
ImmutableMap.Builder<String, String> globalMakeEnvBuilder = ImmutableMap.builder();
for (Fragment fragment : fragments.values()) {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java
index b760ea1..5f62dea 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigSettingTest.java
@@ -273,6 +273,18 @@
assertThat(getConfigMatchingProvider("//test:match").matches()).isFalse();
}
+ /** Tests disallowing {@link BuildConfiguration.Fragment#lateBoundOptionDefaults} */
+ @Test
+ public void disallowLateBoundOptionDefaultsIncompatible() throws Exception {
+ useConfiguration("--incompatible_enable_late_bound_option_defaults=false");
+ scratch.file(
+ "test/BUILD",
+ "config_setting(",
+ " name = 'match',",
+ " values = { 'opt_with_default': 'overridden' }",
+ ")");
+ assertThat(getConfigMatchingProvider("//test:match").matches()).isFalse();
+ }
/**
* Tests matching on multi-value attributes with key=value entries (e.g. --define).
*/