--- swift/utils/build-script-impl.orig	2024-06-06 04:26:30 UTC
+++ swift/utils/build-script-impl
@@ -22,6 +22,8 @@
 set -e
 
 umask 0022
+
+python3=/usr/local/bin/python3.11
 
 # Declare the set of known settings along with each one's description
 #
@@ -345,7 +347,7 @@
 }
 
 function quoted_print() {
-    python3 -c 'import shlex; import sys; print(" ".join(shlex.quote(arg) for arg in sys.argv[1:]))' "$@"
+    ${python3} -c 'import shlex; import sys; print(" ".join(shlex.quote(arg) for arg in sys.argv[1:]))' "$@"
 }
 
 function toupper() {
@@ -461,7 +463,7 @@
 function verify_host_is_supported() {
     local host="$1"
     case ${host} in
-      freebsd-arm64             \
+      freebsd-aarch64           \
       | freebsd-x86_64          \
       | openbsd-amd64           \
       | cygwin-x86_64           \
@@ -2353,7 +2355,7 @@
                       XCTEST_BUILD_ARGS="--release"
                   fi
 
-                  call python3 "${XCTEST_SOURCE_DIR}"/build_script.py \
+                  call ${python3} "${XCTEST_SOURCE_DIR}"/build_script.py \
                       --swiftc="${SWIFTC_BIN}" \
                       --build-dir="${XCTEST_BUILD_DIR}" \
                       --foundation-build-dir="${FOUNDATION_BUILD_DIR}" \
@@ -2848,7 +2850,7 @@
                   echo "--- Running tests for ${product} ---"
                   FOUNDATION_BUILD_DIR=$(build_directory ${host} foundation)
                   XCTEST_BUILD_DIR=$(build_directory ${host} xctest)
-                  call python3 "${XCTEST_SOURCE_DIR}"/build_script.py test \
+                  call ${python3} "${XCTEST_SOURCE_DIR}"/build_script.py test \
                       --swiftc="${SWIFTC_BIN}" \
                       --lit="${LLVM_SOURCE_DIR}/utils/lit/lit.py" \
                       --foundation-build-dir="${FOUNDATION_BUILD_DIR}" \
@@ -3391,7 +3393,7 @@
               call tar -c -z -f "${package_for_host}" "${TOOLCHAIN_PREFIX/#\/}"
         else
             # BSD tar doesn't support --owner/--group.
-            if [[ "$(uname -s)" == "Darwin" || "$(uname -s)" == "FreeBSD" ]] ; then
+            if [[ "$(uname -s)" == "Darwin" || "$(uname -s)" == "FreeBSD" || "$(uname -s)" == "MidnightBSD" ]] ; then
                 with_pushd "${host_install_destdir}" \
                     tar -c -z -f "${package_for_host}" "${host_install_prefix/#\/}"
             else
@@ -3418,11 +3420,11 @@
             with_pushd "${PKG_TESTS_SANDBOX_PARENT}" \
                 call tar xzf "${package_for_host}"
 
-            if python3 -c "import psutil" ; then
+            if ${python3} -c "import psutil" ; then
               TIMEOUT_ARGS=--timeout=600 # 10 minutes
             fi
             with_pushd "${PKG_TESTS_SOURCE_DIR}" \
-                call python3 "${LIT_EXECUTABLE_PATH}" . ${LLVM_LIT_ARGS} --param package-path="${PKG_TESTS_SANDBOX}" --param test-exec-root="${PKG_TESTS_TEMPS}" --param llvm-bin-dir="${LLVM_BIN_DIR}" ${TIMEOUT_ARGS}
+                call ${python3} "${LIT_EXECUTABLE_PATH}" . ${LLVM_LIT_ARGS} --param package-path="${PKG_TESTS_SANDBOX}" --param test-exec-root="${PKG_TESTS_TEMPS}" --param llvm-bin-dir="${LLVM_BIN_DIR}" ${TIMEOUT_ARGS}
         fi
     fi
 }
