From 5e6c5c476700f9bd27b6a4fb217859edcb466a28 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Mon, 6 May 2024 21:18:03 +0800
Subject: [PATCH] toolchain.m4: hack around a broken Xcode version detect

Xcode version detection may or may not work. When it does not, it breaks configure.
Thankfully, we do not need it at all on Darwin PowerPC.

---
 common/autoconf/generated-configure.sh | 19 ++-----------------
 common/autoconf/toolchain.m4           | 16 +---------------
 2 files changed, 3 insertions(+), 32 deletions(-)

diff --git common/autoconf/generated-configure.sh common/autoconf/generated-configure.sh
index 6f17436eff..fcef8fb4e2 100644
--- common/autoconf/generated-configure.sh
+++ common/autoconf/generated-configure.sh
@@ -26102,22 +26102,7 @@ fi
   VALID_TOOLCHAINS=${!toolchain_var_name}
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On Mac OS X, default toolchain to clang after Xcode 5
-    XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1`
-    $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
-    if test $? -ne 0; then
-      as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5
-    fi
-    XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
-        $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \
-        $CUT -f 1 -d .`
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5
-$as_echo "$as_me: Xcode major version: $XCODE_MAJOR_VERSION" >&6;}
-    if test $XCODE_MAJOR_VERSION -ge 5; then
-        DEFAULT_TOOLCHAIN="clang"
-    else
-        DEFAULT_TOOLCHAIN="gcc"
-    fi
+    DEFAULT_TOOLCHAIN="gcc"
   else
     # First toolchain type in the list is the default
     DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
@@ -27518,7 +27503,7 @@ $as_echo "$as_me: or run \"bash.exe -l\" from a VS command prompt and then run c
     SET_DEVELOPER_DIR=
 
     if test -n "$XCODE_PATH"; then
-      DEVELOPER_DIR="$XCODE_PATH"/Contents/Developer
+      DEVELOPER_DIR="$XCODE_PATH"/Developer
     fi
 
     # DEVELOPER_DIR could also be provided directly
diff --git common/autoconf/toolchain.m4 common/autoconf/toolchain.m4
index ba4798e795..353ce121e4 100644
--- common/autoconf/toolchain.m4
+++ common/autoconf/toolchain.m4
@@ -151,21 +151,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE],
   VALID_TOOLCHAINS=${!toolchain_var_name}
  
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On Mac OS X, default toolchain to clang after Xcode 5
-    XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1`
-    $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null
-    if test $? -ne 0; then
-      AC_MSG_ERROR([Failed to determine Xcode version.])
-    fi
-    XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \
-        $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \
-        $CUT -f 1 -d .`
-    AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION])
-    if test $XCODE_MAJOR_VERSION -ge 5; then
-        DEFAULT_TOOLCHAIN="clang"
-    else
-        DEFAULT_TOOLCHAIN="gcc"
-    fi
+    DEFAULT_TOOLCHAIN="gcc"
   else
     # First toolchain type in the list is the default
     DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *}
