Automated rollback of commit 324dc44e6bafb487331724ae83d67bc18ed8a8aa.

*** Reason for rollback ***

Broke determinism test: https://buildkite.com/bazel/bazel-bazel/builds/8716#80234b87-27d6-42e7-ab16-ab15dc8ecbcb

*** Original change description ***

Embed @platforms into the Bazel binary

This PR implements the change discussed at https://docs.google.com/document/d/1EArrWYUDugqJzBcb0-OxY5BH1FFPYV3jxLIXbJpD9RY/edit?pli=1#heading=h.5mcn15i0e1ch.

Closes https://github.com/bazelbuild/bazel/issues/8596

Closes #8600.

PiperOrigin-RevId: 253002611
diff --git a/BUILD b/BUILD
index 8e21037..4aef01e 100644
--- a/BUILD
+++ b/BUILD
@@ -78,15 +78,6 @@
     visibility = ["//:__subpackages__"],
 )
 
-pkg_tar(
-    name = "platforms-srcs",
-    srcs = ["@platforms//:srcs"],
-    package_dir = "platforms",
-    strip_prefix = ".",
-    # Public but bazel-only visibility.
-    visibility = ["//:__subpackages__"],
-)
-
 py_binary(
     name = "combine_distfiles",
     srcs = ["combine_distfiles.py"],
@@ -98,7 +89,6 @@
     name = "bazel-distfile",
     srcs = [
         ":bazel-srcs",
-        ":platforms-srcs",
         "//src:derived_java_srcs",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
         "@additional_distfiles//:archives.tar",
@@ -114,7 +104,6 @@
     name = "bazel-distfile-tar",
     srcs = [
         ":bazel-srcs",
-        ":platforms-srcs",
         "//src:derived_java_srcs",
         "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
         "@additional_distfiles//:archives.tar",
diff --git a/WORKSPACE b/WORKSPACE
index f6767e2..b549a4c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -497,16 +497,6 @@
 )
 
 http_archive(
-    name = "platforms",
-    sha256 = "a07fe5e75964361885db725039c2ba673f0ee0313d971ae4f50c9b18cd28b0b5",
-    urls = [
-        "https://mirror.bazel.build/github.com/bazelbuild/platforms/archive/441afe1bfdadd6236988e9cac159df6b5a9f5a98.zip",
-        "https://github.com/bazelbuild/platforms/archive/441afe1bfdadd6236988e9cac159df6b5a9f5a98.zip",
-    ],
-    strip_prefix = "platforms-441afe1bfdadd6236988e9cac159df6b5a9f5a98"
-)
-
-http_archive(
     name = "java_tools_langtools_javac12",
     sha256 = "99b107105165a91df82cd7cf82a8efb930d803fb7de1663cf7f780142104cd14",
     urls = [
diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh
index 90782f9..069ee91 100755
--- a/scripts/bootstrap/compile.sh
+++ b/scripts/bootstrap/compile.sh
@@ -289,9 +289,6 @@
 ARCHIVE_DIR=${OUTPUT_DIR}/archive
 mkdir -p ${ARCHIVE_DIR}/_embedded_binaries
 
-# Prepare @platforms local repository
-link_dir ${PWD}/platforms ${ARCHIVE_DIR}/_embedded_binaries/platforms
-
 # Dummy build-runfiles (we can't compile C++ yet, so we can't have the real one)
 if [ "${PLATFORM}" = "windows" ]; then
   # We don't rely on runfiles trees on Windows
diff --git a/src/BUILD b/src/BUILD
index 783cfef..c0e70b8 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -328,11 +328,10 @@
     name = "package-zip" + suffix,
     srcs = ([":embedded_tools" + suffix + ".zip"] if embed else []) + [
         # The script assumes that the embedded tools zip (if exists) is the
-        # first item here, the deploy jar the second, install base key is the
-        # third, and platforms archive is the fourth.
+        # first item here, the deploy jar the second and install base key is the
+        # third
         "//src/main/java/com/google/devtools/build/lib:bazel/BazelServer_deploy.jar",
         "install_base_key" + suffix,
-        ":platforms_archive",
         ":libunix",
         "//src/main/tools:build-runfiles",
         "//src/main/tools:process-wrapper",
@@ -356,13 +355,6 @@
     ("_nojdk", True),
 ]]
 
-genrule(
-    name = "platforms_archive",
-    srcs = ["@platforms//:srcs"],
-    outs = ["platforms.zip"],
-    cmd = "zip -qX $@ $$(echo $(SRCS) | sort)",
-)
-
 [genrule(
     name = "bazel-bin" + suffix,
     srcs = [
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE
index d345d0b..d0ce5b7 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/local_config_platform.WORKSPACE
@@ -1,6 +1 @@
-local_repository(
-    name = "platforms",
-    path = __embedded_dir__ + "/platforms",
-)
-
 local_config_platform(name = "local_config_platform")
diff --git a/src/package-bazel.sh b/src/package-bazel.sh
index fec5d0b..632b133 100755
--- a/src/package-bazel.sh
+++ b/src/package-bazel.sh
@@ -16,15 +16,16 @@
 
 set -euo pipefail
 
-# This script creates the Bazel archive that Bazel client unpacks and then
-# starts the server from.
+# This script bootstraps building a Bazel binary without Bazel then
+# use this compiled Bazel to bootstrap Bazel itself. It can also
+# be provided with a previous version of Bazel to bootstrap Bazel
+# itself.
 
 WORKDIR=$(pwd)
 OUT=$1
 EMBEDDED_TOOLS=$2
 DEPLOY_JAR=$3
 INSTALL_BASE_KEY=$4
-PLATFORMS_ARCHIVE=$5
 shift 4
 
 TMP_DIR=${TMPDIR:-/tmp}
@@ -65,15 +66,4 @@
   (cd ${PACKAGE_DIR}/embedded_tools && unzip -q "${WORKDIR}/${EMBEDDED_TOOLS}")
 fi
 
-# Unzip platforms.zip into platforms/, move files up from external/platforms
-# subdirectory, and cleanup after itself.
-( \
-  cd ${PACKAGE_DIR} && \
-    unzip -q -d platforms platforms.zip && \
-    rm platforms.zip && \
-    cd platforms && \
-    mv external/platforms/* . && \
-    rmdir -p external/platforms \
-)
-
 (cd ${PACKAGE_DIR} && find . -type f | sort | zip -q9DX@ "${WORKDIR}/${OUT}")
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index e085eee..1a773ce 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -1104,13 +1104,6 @@
 )
 
 sh_test(
-    name = "platforms_test",
-    srcs = ["platforms_test.sh"],
-    data = [":test-deps"],
-    deps = ["@bazel_tools//tools/bash/runfiles"],
-)
-
-sh_test(
     name = "platform_mapping_test",
     srcs = ["platform_mapping_test.sh"],
     data = [":test-deps"],
diff --git a/src/test/shell/bazel/platforms_test.sh b/src/test/shell/bazel/platforms_test.sh
deleted file mode 100755
index 6db625a..0000000
--- a/src/test/shell/bazel/platforms_test.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2019 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Test related to @platforms embedded repository
-#
-
-# --- begin runfiles.bash initialization ---
-set -euo pipefail
-if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
-  if [[ -f "$0.runfiles_manifest" ]]; then
-    export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
-  elif [[ -f "$0.runfiles/MANIFEST" ]]; then
-    export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
-  elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
-    export RUNFILES_DIR="$0.runfiles"
-  fi
-fi
-if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
-  source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
-elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
-  source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
-            "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
-else
-  echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
-  exit 1
-fi
-# --- end runfiles.bash initialization ---
-
-source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
-  || { echo "integration_test_setup.sh not found!" >&2; exit 1; }
-
-function test_platforms_repository_builds_itself() {
-  # We test that a built-in @platforms repository is buildable.
-  bazel build @platforms//:all &> $TEST_log \
-      || fail "Build failed unexpectedly"
-}
-
-function test_platforms_can_be_overridden() {
-  # We test that a custom repository can override @platforms in their
-  # WORKSPACE file.
-  mkdir -p platforms_can_be_overridden || fail "couldn't create directory"
-  touch platforms_can_be_overridden/BUILD || \ fail "couldn't touch BUILD file"
-  cat > platforms_can_be_overridden/WORKSPACE <<EOF
-local_repository(
-  name = 'platforms',
-  path = '../override',
-)
-EOF
-
-  mkdir -p override || fail "couldn't create override directory"
-  touch override/WORKSPACE || fail "couldn't touch override/WORKSPACE"
-  cat > override/BUILD <<EOF
-filegroup(name = 'yolo')
-EOF
-
-  cd platforms_can_be_overridden || fail "couldn't cd into workspace"
-  bazel build @platforms//:yolo &> $TEST_log || \
-    fail "Bazel failed to build @platforms"
-}
-
-run_suite "platform mapping test"
-