Cherry-pick required commits into 7.0.0-pre.20230810.1rc1 (#19298)

-
https://github.com/bazelbuild/bazel/commit/138f06fc90a5a238cc505ac075178889f7efb687
-
https://github.com/bazelbuild/bazel/commit/d0de5e044c65fe7c5e414f860887be20087732da

---------

Co-authored-by: Googler <pcloudy@google.com>
diff --git a/.bazelci/build_bazel_binaries.yml b/.bazelci/build_bazel_binaries.yml
index 337ad76..2670bf4 100644
--- a/.bazelci/build_bazel_binaries.yml
+++ b/.bazelci/build_bazel_binaries.yml
@@ -52,8 +52,7 @@
       - "--host_copt=-w"
       - "-c"
       - "opt"
-      - "--cpu=x64_arm64_windows"
-      - "--incompatible_enable_cc_toolchain_resolution"
+      - "--config=windows_arm64"
     build_targets:
       - "//src:bazel.exe"
       - "//src:bazel_nojdk.exe"
diff --git a/.bazelrc b/.bazelrc
index 16c688a..f59dfd2 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -32,6 +32,9 @@
 # Therefore, use the local detected Python toolchain on Windows.
 build:windows --extra_toolchains=@bazel_tools//tools/python:autodetecting_toolchain
 
+build:windows_arm64 --platforms=//:windows_arm64
+build:windows_arm64 --extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows
+
 # Enable Bzlmod
 build:bzlmod --enable_bzlmod
 build:bzlmod --check_direct_dependencies=error
diff --git a/BUILD b/BUILD
index 0540bb8..ce2faae 100644
--- a/BUILD
+++ b/BUILD
@@ -248,6 +248,14 @@
     parents = ["@local_config_platform//:host"],
 )
 
+platform(
+    name = "windows_arm64",
+    constraint_values = [
+        "@platforms//os:windows",
+        "@platforms//cpu:arm64",
+    ],
+)
+
 REMOTE_PLATFORMS = ("rbe_ubuntu1804_java11",)
 
 [
diff --git a/third_party/blake3/blake3.BUILD b/third_party/blake3/blake3.BUILD
index 867e33f..f141a9c 100644
--- a/third_party/blake3/blake3.BUILD
+++ b/third_party/blake3/blake3.BUILD
@@ -58,6 +58,9 @@
 	    "-DBLAKE3_NO_AVX512",
 	],
         "@bazel_tools//src/conditions:windows_x64": [],
+        "@bazel_tools//src/conditions:windows_arm64": [
+            "-DBLAKE3_USE_NEON=0",
+        ],
         "@bazel_tools//src/conditions:darwin_arm64": [
             "-DBLAKE3_USE_NEON=1",
         ],