Repository: bazelbuild/bazel
Issue: incompatible_disallow_rule_execution_platform_constraints_allowed: Disallow the execution_platform_constraints_allowed attribute to rule
Labels: team-Configurability
incompatible-change

As part of #8134, we need to remove the `execution_platform_constraints_allowed` attribute to Starlark's `rule()` function. After the attribute is removed, all targets will be able to use `exec_compatible_with` to add restrictions on the execution platform.

# Migration

Remove any existing uses of `execution_platform_constraints_allowed` from rules. All rules will be able to use `execution_platform_constraints`.

# Timeline

Flag added: Bazel 0.26
Flag flipped: Bazel 0.27 (expected)


Issue comments:
According to https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/191#annotation-flags_ready_to_flip this is ready to go after 0.29 is cut.
This flag is now flipped.

Pull request review comments:

Patch that resolved the issue:
diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
index 0b28c8635390e1..ed59d033834f2c 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkSemanticsOptions.java
@@ -386,7 +386,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
 
   @Option(
       name = "incompatible_disallow_rule_execution_platform_constraints_allowed",
-      defaultValue = "False",
+      defaultValue = "True",
       documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
       effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
       metadataTags = {
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
index 9865368bd63ecd..58fe2c502c62de 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkSemantics.java
@@ -276,7 +276,7 @@ public static Builder builderWithDefaults() {
           .incompatibleDisallowLegacyJavaProvider(false)
           .incompatibleDisallowLegacyJavaInfo(false)
           .incompatibleDisallowOldStyleArgsAdd(true)
-          .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(false)
+          .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(true)
           .incompatibleDisallowStructProviderSyntax(false)
           .incompatibleDisallowUnverifiedHttpDownloads(true)
           .incompatibleExpandDirectories(true)


Test patch:
diff --git a/src/test/shell/bazel/toolchain_test.sh b/src/test/shell/bazel/toolchain_test.sh
index 5b4f707b4c5905..1b75ce1155fa5d 100755
--- a/src/test/shell/bazel/toolchain_test.sh
+++ b/src/test/shell/bazel/toolchain_test.sh
@@ -1003,7 +1003,6 @@ sample_rule = rule(
   implementation = _impl,
   attrs = {},
   toolchains = ['//toolchain:test_toolchain'],
-  execution_platform_constraints_allowed = True,
 )
 EOF
 
@@ -1074,7 +1073,6 @@ sample_rule = rule(
     '//platforms:value2',
   ],
   toolchains = ['//toolchain:test_toolchain'],
-  execution_platform_constraints_allowed = True,
 )
 EOF
 
@@ -1453,7 +1451,6 @@ sample_rule = rule(
   attrs = {
     "dep": attr.label(cfg = 'exec'),
   },
-  execution_platform_constraints_allowed = True,
 )
 
 def _display_platform_impl(ctx):