Finish removing enabled toolchain types.

Final part of #10262.

PiperOrigin-RevId: 300122691
diff --git a/site/docs/user-manual.html b/site/docs/user-manual.html
index cc54e8f..1c31494 100644
--- a/site/docs/user-manual.html
+++ b/site/docs/user-manual.html
@@ -1571,13 +1571,6 @@
   toolchains.
 </p>
 
-<h4 id="flag--enabled_toolchain_types"><code class='flag'>--enabled_toolchain_types <var>labels</var></code></h4>
-<p>
-  Enable toolchain resolution for the given toolchain type, if the rules used support that.
-  This does not directly change the core Bazel machinery, but is a signal to participating rule
-  implementations that toolchain resolution should be used.
-</p>
-
 <h3 id='misc_build_options'>Miscellaneous</h3>
 
 <h4 id='flag--symlink_prefix'><code class='flag'>--symlink_prefix <var>string</var></code></h4>
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java
index 1234456..955a903 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java
@@ -34,7 +34,6 @@
   private final ImmutableList<String> extraExecutionPlatforms;
   private final Label targetPlatform;
   private final ImmutableList<String> extraToolchains;
-  private final ImmutableList<Label> enabledToolchainTypes;
   private final List<Map.Entry<RegexFilter, List<Label>>> targetFilterToAdditionalExecConstraints;
 
   PlatformConfiguration(
@@ -42,13 +41,11 @@
       ImmutableList<String> extraExecutionPlatforms,
       Label targetPlatform,
       ImmutableList<String> extraToolchains,
-      ImmutableList<Label> enabledToolchainTypes,
       List<Map.Entry<RegexFilter, List<Label>>> targetFilterToAdditionalExecConstraints) {
     this.hostPlatform = hostPlatform;
     this.extraExecutionPlatforms = extraExecutionPlatforms;
     this.targetPlatform = targetPlatform;
     this.extraToolchains = extraToolchains;
-    this.enabledToolchainTypes = enabledToolchainTypes;
     this.targetFilterToAdditionalExecConstraints = targetFilterToAdditionalExecConstraints;
   }
 
@@ -101,11 +98,6 @@
     return extraToolchains;
   }
 
-  @Override
-  public List<Label> getEnabledToolchainTypes() {
-    return enabledToolchainTypes;
-  }
-
   /**
    * Returns a list of labels referring to additional constraint value targets which should be taken
    * into account when resolving the toolchains/execution platform for the target with the given
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java
index a76c2bd..694b614 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java
@@ -39,7 +39,6 @@
         ImmutableList.copyOf(platformOptions.extraExecutionPlatforms),
         platformOptions.computeTargetPlatform(),
         ImmutableList.copyOf(platformOptions.extraToolchains),
-        ImmutableList.copyOf(platformOptions.enabledToolchainTypes),
         platformOptions.targetFilterToAdditionalExecConstraints);
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
index 44442d6b..2aea623 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
@@ -157,21 +157,6 @@
   public boolean toolchainResolutionDebug;
 
   @Option(
-      name = "enabled_toolchain_types",
-      defaultValue = "",
-      converter = LabelListConverter.class,
-      documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
-      effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
-      deprecationWarning =
-          "Use --incompatible_enable_cc_toolchain_resolution to enable toolchain for cc rules. "
-              + "Other rules will define separate flags as needed.",
-      help =
-          "Enable toolchain resolution for the given toolchain type, if the rules used support "
-              + "that. This does not directly change the core Blaze machinery, but is a signal to "
-              + "participating rule implementations that toolchain resolution should be used.")
-  public List<Label> enabledToolchainTypes;
-
-  @Option(
       name = "incompatible_auto_configure_host_platform",
       defaultValue = "true",
       documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
@@ -242,7 +227,6 @@
     host.platformMappings = this.platformMappings;
     host.extraExecutionPlatforms = this.extraExecutionPlatforms;
     host.extraToolchains = this.extraToolchains;
-    host.enabledToolchainTypes = this.enabledToolchainTypes;
     host.toolchainResolutionDebug = this.toolchainResolutionDebug;
     host.toolchainResolutionOverrides = this.toolchainResolutionOverrides;
     host.autoConfigureHostPlatform = this.autoConfigureHostPlatform;
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 e5cfe5a..a6443a4 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
@@ -551,20 +551,6 @@
   public boolean incompatibleNoTargetOutputGroup;
 
   @Option(
-      name = "incompatible_remove_enabled_toolchain_types",
-      defaultValue = "true",
-      documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
-      effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
-      metadataTags = {
-        OptionMetadataTag.INCOMPATIBLE_CHANGE,
-        OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
-      },
-      help =
-          "If set to true, the platform configuration fragment cannot access the (deprecated) list"
-              + " of enabled toolchain types.")
-  public boolean incompatibleRemoveEnabledToolchainTypes;
-
-  @Option(
       name = "incompatible_run_shell_command_string",
       defaultValue = "false",
       documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
@@ -717,7 +703,6 @@
             .incompatibleNoRuleOutputsParam(incompatibleNoRuleOutputsParam)
             .incompatibleNoSupportToolsInActionInputs(incompatibleNoSupportToolsInActionInputs)
             .incompatibleNoTargetOutputGroup(incompatibleNoTargetOutputGroup)
-            .incompatibleRemoveEnabledToolchainTypes(incompatibleRemoveEnabledToolchainTypes)
             .incompatibleRestrictNamedParams(incompatibleRestrictNamedParams)
             .incompatibleRunShellCommandString(incompatibleRunShellCommandString)
             .incompatibleVisibilityPrivateAttributesAtDefinition(
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java
index 8d217bf..316944d 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/platform/PlatformConfigurationApi.java
@@ -19,9 +19,7 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
 import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
-import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;
 import com.google.devtools.build.lib.syntax.StarlarkValue;
-import java.util.List;
 
 /** The platform configuration. */
 @SkylarkModule(
@@ -43,11 +41,4 @@
       documented = false)
   @Deprecated
   ImmutableList<Label> getTargetPlatforms();
-
-  @SkylarkCallable(
-      name = "enabled_toolchain_types",
-      structField = true,
-      disableWithFlag = FlagIdentifier.INCOMPATIBLE_REMOVE_ENABLE_TOOLCHAIN_TYPES,
-      doc = "The set of toolchain types enabled for platform-based toolchain selection.")
-  List<Label> getEnabledToolchainTypes();
 }
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 6ebe823..1aedd1fd 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
@@ -83,8 +83,6 @@
     public static final String INCOMPATIBLE_NO_ATTR_LICENSE = "incompatible_no_attr_license";
     public static final String INCOMPATIBLE_ALLOW_TAGS_PROPAGATION =
         "incompatible_allow_tags_propagation";
-    public static final String INCOMPATIBLE_REMOVE_ENABLE_TOOLCHAIN_TYPES =
-        "incompatible_remove_enable_toolchain_types";
     public static final String INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API =
         "incompatible_require_linker_input_cc_api";
     public static final String INCOMPATIBLE_LINKOPTS_TO_LINKLIBS =
@@ -137,8 +135,6 @@
         return incompatibleNoAttrLicense();
       case FlagIdentifier.INCOMPATIBLE_ALLOW_TAGS_PROPAGATION:
         return experimentalAllowTagsPropagation();
-      case FlagIdentifier.INCOMPATIBLE_REMOVE_ENABLE_TOOLCHAIN_TYPES:
-        return incompatibleRemoveEnabledToolchainTypes();
       case FlagIdentifier.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API:
         return incompatibleRequireLinkerInputCcApi();
       case FlagIdentifier.INCOMPATIBLE_LINKOPTS_TO_LINKLIBS:
@@ -250,8 +246,6 @@
 
   public abstract boolean incompatibleNoTargetOutputGroup();
 
-  public abstract boolean incompatibleRemoveEnabledToolchainTypes();
-
   public abstract boolean incompatibleRestrictNamedParams();
 
   public abstract boolean incompatibleRunShellCommandString();
@@ -341,7 +335,6 @@
           .incompatibleNoRuleOutputsParam(false)
           .incompatibleNoSupportToolsInActionInputs(true)
           .incompatibleNoTargetOutputGroup(true)
-          .incompatibleRemoveEnabledToolchainTypes(true)
           .incompatibleRunShellCommandString(false)
           .incompatibleRestrictNamedParams(true)
           .incompatibleVisibilityPrivateAttributesAtDefinition(false)
@@ -427,8 +420,6 @@
 
     public abstract Builder incompatibleNoTargetOutputGroup(boolean value);
 
-    public abstract Builder incompatibleRemoveEnabledToolchainTypes(boolean value);
-
     public abstract Builder incompatibleRestrictNamedParams(boolean value);
 
     public abstract Builder incompatibleRunShellCommandString(boolean value);
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index 3ced730..f1d6490 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -159,7 +159,6 @@
         "--incompatible_no_rule_outputs_param=" + rand.nextBoolean(),
         "--incompatible_no_support_tools_in_action_inputs=" + rand.nextBoolean(),
         "--incompatible_no_target_output_group=" + rand.nextBoolean(),
-        "--incompatible_remove_enabled_toolchain_types=" + rand.nextBoolean(),
         "--incompatible_restrict_named_params=" + rand.nextBoolean(),
         "--incompatible_run_shell_command_string=" + rand.nextBoolean(),
         "--incompatible_visibility_private_attributes_at_definition=" + rand.nextBoolean(),
@@ -214,7 +213,6 @@
         .incompatibleNoRuleOutputsParam(rand.nextBoolean())
         .incompatibleNoSupportToolsInActionInputs(rand.nextBoolean())
         .incompatibleNoTargetOutputGroup(rand.nextBoolean())
-        .incompatibleRemoveEnabledToolchainTypes(rand.nextBoolean())
         .incompatibleRestrictNamedParams(rand.nextBoolean())
         .incompatibleRunShellCommandString(rand.nextBoolean())
         .incompatibleVisibilityPrivateAttributesAtDefinition(rand.nextBoolean())
diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformConfigurationApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformConfigurationApiTest.java
index d2feb5f..eb6d251 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformConfigurationApiTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformConfigurationApiTest.java
@@ -14,7 +14,6 @@
 package com.google.devtools.build.lib.rules.platform;
 
 import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.devtools.build.lib.analysis.ConfiguredTarget;
@@ -22,7 +21,6 @@
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.packages.SkylarkProvider.SkylarkKey;
 import com.google.devtools.build.lib.packages.StructImpl;
-import java.util.List;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
@@ -94,82 +92,4 @@
     Label targetPlatform = (Label) info.getValue("target_platform");
     assertThat(targetPlatform).isEqualTo(Label.parseAbsoluteUnchecked("//platforms:test_platform"));
   }
-
-  @Test
-  public void testEnabledToolchainTypes() throws Exception {
-    scratch.file(
-        "toolchains/BUILD",
-        "toolchain_type(name = 'test_toolchain_type1')",
-        "toolchain_type(name = 'test_toolchain_type2')",
-        "toolchain_type(name = 'test_toolchain_type3')");
-
-    scratch.file(
-        "verify/verify.bzl",
-        "result = provider()",
-        "def _impl(ctx):",
-        "  platformConfig = ctx.fragments.platform",
-        "  enabled_toolchain_types = platformConfig.enabled_toolchain_types",
-        "  return [result(",
-        "    enabled_toolchain_types = enabled_toolchain_types,",
-        "  )]",
-        "verify = rule(",
-        "  implementation = _impl,",
-        "  fragments = ['platform'],",
-        ")");
-    scratch.file("verify/BUILD", "load(':verify.bzl', 'verify')", "verify(name = 'verify',", ")");
-
-    setSkylarkSemanticsOptions("--incompatible_remove_enabled_toolchain_types=false");
-    useConfiguration(
-        "--enabled_toolchain_types="
-            + "//toolchains:test_toolchain_type1,//toolchains:test_toolchain_type3");
-
-    ConfiguredTarget myRuleTarget = getConfiguredTarget("//verify:verify");
-    StructImpl info =
-        (StructImpl)
-            myRuleTarget.get(
-                new SkylarkKey(
-                    Label.parseAbsolute("//verify:verify.bzl", ImmutableMap.of()), "result"));
-
-    @SuppressWarnings("unchecked")
-    List<Label> enabledToolchainTypes = (List<Label>) info.getValue("enabled_toolchain_types");
-    assertThat(enabledToolchainTypes)
-        .containsExactly(
-            Label.parseAbsoluteUnchecked("//toolchains:test_toolchain_type1"),
-            Label.parseAbsoluteUnchecked("//toolchains:test_toolchain_type3"));
-  }
-
-  @Test
-  public void testEnabledToolchainTypes_disabled() throws Exception {
-    scratch.file(
-        "toolchains/BUILD",
-        "toolchain_type(name = 'test_toolchain_type1')",
-        "toolchain_type(name = 'test_toolchain_type2')",
-        "toolchain_type(name = 'test_toolchain_type3')");
-
-    scratch.file(
-        "verify/verify.bzl",
-        "result = provider()",
-        "def _impl(ctx):",
-        "  platformConfig = ctx.fragments.platform",
-        "  enabled_toolchain_types = platformConfig.enabled_toolchain_types",
-        "  return [result(",
-        "    enabled_toolchain_types = enabled_toolchain_types,",
-        "  )]",
-        "verify = rule(",
-        "  implementation = _impl,",
-        "  fragments = ['platform'],",
-        ")");
-    scratch.file("verify/BUILD", "load(':verify.bzl', 'verify')", "verify(name = 'verify',", ")");
-
-    setSkylarkSemanticsOptions("--incompatible_remove_enabled_toolchain_types");
-    useConfiguration(
-        "--enabled_toolchain_types="
-            + "//toolchains:test_toolchain_type1,//toolchains:test_toolchain_type3");
-
-    AssertionError error =
-        assertThrows(AssertionError.class, () -> getConfiguredTarget("//verify:verify"));
-    assertThat(error)
-        .hasMessageThat()
-        .contains("'platform' value has no field or method 'enabled_toolchain_types'");
-  }
 }