Flip --noexperimental_enable_aggregating_middleman for Bazel.

This would disables the use of AggregatingMiddleman in Bazel. There's no expected significant performance hit, since NSOS was flipped for Bazel a while back.

Benchmark (local specialist machine, runs=5):
RESULTS:
Bazel commit: /tmp/bazel-base, Project commit: beb859d52a22d467f430c58246eb767a98cbf871, Project source: https://github.com/bazelbuild/bazel.git
  metric          mean                median          stddev      pval
    wall:   94.585s              94.443s              0.782s
     cpu:  111.896s             110.700s              3.313s
  system:   56.986s              55.430s              2.662s
  memory:  101.800MB            102.000MB             0.400MB

Bazel commit: /tmp/bazel-no-mm, Project commit: beb859d52a22d467f430c58246eb767a98cbf871, Project source: https://github.com/bazelbuild/bazel.git
  metric          mean                median          stddev      pval
    wall:   93.420s  ( -1.23%)   93.617s  ( -0.88%)   0.979s     0.92063
     cpu:  113.764s  ( +1.67%)  114.580s  ( +3.50%)   3.178s     0.00000
  system:   52.792s  ( -7.36%)   52.450s  ( -5.38%)   1.741s     0.92063
  memory:  101.800MB ( +0.00%)  102.000MB ( +0.00%)   0.400MB    0.00000

RELNOTES: None
PiperOrigin-RevId: 381246974
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java
index 8fcb9b9..465224b 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java
@@ -806,7 +806,7 @@
 
   @Option(
       name = "experimental_enable_aggregating_middleman",
-      defaultValue = "true",
+      defaultValue = "false",
       documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
       effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
       metadataTags = {OptionMetadataTag.EXPERIMENTAL},
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index 175cb22..519680a 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -43,6 +43,7 @@
 import com.google.devtools.build.lib.actions.ActionResult;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
+import com.google.devtools.build.lib.actions.Artifact.DerivedArtifact;
 import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact;
 import com.google.devtools.build.lib.actions.Artifact.SpecialArtifactType;
 import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;
@@ -782,6 +783,15 @@
         artifacts, artifact -> artifact.getExecPath().getPathString().endsWith(suffix));
   }
 
+  public static Artifact getFirstDerivedArtifactEndingWith(
+      NestedSet<? extends Artifact> artifacts, String suffix) {
+    return getFirstArtifactMatching(
+        artifacts.toList(),
+        artifact ->
+            artifact instanceof DerivedArtifact
+                && artifact.getExecPath().getPathString().endsWith(suffix));
+  }
+
   /** Returns the first Artifact in the provided Iterable that matches the specified predicate. */
   public static Artifact getFirstArtifactMatching(
       Iterable<? extends Artifact> artifacts, Predicate<Artifact> predicate) {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
index 7f05a2c..296a036 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java
@@ -57,7 +57,7 @@
             .getToolchainContext()
             .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE, ImmutableMap.of()));
     CcToolchainProvider toolchain = (CcToolchainProvider) toolchainInfo.getValue("cc");
-    assertThat(toolchain.getCompilerFiles().getSingleton().getExecPathString()).endsWith("k8");
+    assertThat(toolchain.getToolchainIdentifier()).endsWith("k8");
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
index 92bf287..475268e 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainTest.java
@@ -15,14 +15,12 @@
 package com.google.devtools.build.lib.rules.cpp;
 
 import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
 import static org.junit.Assert.assertThrows;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.MoreCollectors;
-import com.google.common.collect.Sets;
 import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
 import com.google.devtools.build.lib.actions.Artifact;
 import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
@@ -39,7 +37,6 @@
 import com.google.devtools.build.lib.testutil.TestConstants;
 import com.google.devtools.common.options.OptionsParsingException;
 import java.io.IOException;
-import java.util.Set;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
@@ -676,37 +673,6 @@
     useConfiguration("--incompatible_use_specific_tool_files");
     ConfiguredTarget target = getConfiguredTarget("//a:a");
     CcToolchainProvider toolchainProvider = target.get(CcToolchainProvider.PROVIDER);
-    // Check that the mock toolchain tool file sets are an antichain, so that our subset assertions
-    // below are meaningful.
-    ImmutableList<Set<Artifact>> fileGroups =
-        ImmutableList.of(
-            toolchainProvider.getArFiles().toSet(),
-            toolchainProvider.getLinkerFiles().toSet(),
-            toolchainProvider.getCompilerFiles().toSet(),
-            toolchainProvider.getAsFiles().toSet(),
-            toolchainProvider.getAllFiles().toSet());
-    for (int i = 0; i < fileGroups.size(); i++) {
-      assertThat(fileGroups.get(i)).isNotEmpty();
-      for (int j = 0; j < fileGroups.size(); j++) {
-        if (i == j) {
-          continue;
-        }
-        Set<Artifact> one = fileGroups.get(i);
-        Set<Artifact> two = fileGroups.get(j);
-        assertWithMessage(String.format("%s should not contain %s", one, two))
-            .that(one.containsAll(two))
-            .isFalse();
-      }
-    }
-    assertThat(
-            Sets.difference(
-                toolchainProvider.getArFiles().toSet(), toolchainProvider.getLinkerFiles().toSet()))
-        .isNotEmpty();
-    assertThat(
-            Sets.difference(
-                toolchainProvider.getLinkerFiles().toSet(), toolchainProvider.getArFiles().toSet()))
-        .isNotEmpty();
-
     RuleConfiguredTarget libTarget = (RuleConfiguredTarget) getConfiguredTarget("//a:l");
     Artifact staticLib =
         getOutputGroup(libTarget, "archive").toList().stream()
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
index 7d7abaf..7124f20 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java
@@ -74,13 +74,6 @@
 
   static final RuleType RULE_TYPE = new OnlyNeedsSourcesRuleType("objc_library");
   private static final String WRAPPED_CLANG = "wrapped_clang";
-
-  /**
-   * Middleman artifact arising from //tools/osx/crosstool:link, containing tools that should be
-   * inputs to link actions.
-   */
-  private static final String CROSSTOOL_LINK_MIDDLEMAN = "tools_Sosx_Scrosstool_Clink";
-
   /** Creates an {@code objc_library} target writer. */
   @Override
   protected ScratchAttributeWriter createLibraryTargetWriter(String labelString) {
@@ -878,7 +871,7 @@
                 "-o",
                 Iterables.getOnlyElement(archiveAction.getOutputs()).getExecPathString()));
     assertThat(baseArtifactNames(archiveAction.getInputs()))
-        .containsAtLeast("a.o", "b.o", "lib-archive.objlist", CROSSTOOL_LINK_MIDDLEMAN);
+        .containsAtLeast("a.o", "b.o", "lib-archive.objlist", "ar", "libempty.a", "libtool");
     assertThat(baseArtifactNames(archiveAction.getOutputs())).containsExactly("liblib.a");
     assertRequiresDarwin(archiveAction);
   }
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
index 6bf9c01..d50a0e5 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
@@ -18,6 +18,7 @@
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth8.assertThat;
 import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith;
+import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstDerivedArtifactEndingWith;
 import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MODULE_MAP;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.LIPO;
 import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SRCS_TYPE;
@@ -1407,9 +1408,9 @@
 
     // If bin is indeed using the c++ backend, then its archive action should be a CppLinkAction.
     Action lipobinAction = lipoBinAction("//x:x");
-    Artifact bin = getFirstArtifactEndingWith(lipobinAction.getInputs(), "_bin");
+    Artifact bin = getFirstDerivedArtifactEndingWith(lipobinAction.getInputs(), "_bin");
     Action linkAction = getGeneratingAction(bin);
-    Artifact archive = getFirstArtifactEndingWith(linkAction.getInputs(), ".a");
+    Artifact archive = getFirstDerivedArtifactEndingWith(linkAction.getInputs(), ".a");
     Action archiveAction = getGeneratingAction(archive);
     assertThat(archiveAction).isInstanceOf(CppLinkAction.class);
   }
@@ -1420,9 +1421,9 @@
 
     // If bin is indeed using the c++ backend, then its archive action should be a CppLinkAction.
     Action lipobinAction = lipoBinAction("//x:x");
-    Artifact bin = getFirstArtifactEndingWith(lipobinAction.getInputs(), "_bin");
+    Artifact bin = getFirstDerivedArtifactEndingWith(lipobinAction.getInputs(), "_bin");
     Action linkAction = getGeneratingAction(bin);
-    Artifact archive = getFirstArtifactEndingWith(linkAction.getInputs(), ".a");
+    Artifact archive = getFirstDerivedArtifactEndingWith(linkAction.getInputs(), ".a");
     Action archiveAction = getGeneratingAction(archive);
     assertThat(archiveAction).isInstanceOf(CppLinkAction.class);
   }