From dec7600d990102547057a120165c0cc31a631064 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Sat, 22 Nov 2025 20:43:48 +0700
Subject: [PATCH 4/7] configure the host triple on an Apple Silicon machine
 correctly

Backports https://github.com/llvm/llvm-project/commit/050ed9720f84343d859c530b8b692eb6141e6a63
---
 llvm/cmake/config.guess | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git llvm/cmake/config.guess llvm/cmake/config.guess
index ccb30f4e75e..678435bec23 100644
--- llvm/cmake/config.guess
+++ llvm/cmake/config.guess
@@ -1239,6 +1239,23 @@ EOF
 		      UNAME_PROCESSOR="x86_64"
 		  fi
 		fi ;;
+		arm)
+		eval $set_cc_for_build
+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+			if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+				(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+				grep IS_64BIT_ARCH >/dev/null
+			then
+				if (echo '#ifdef __PTRAUTH_INTRINSICS__'; echo HAS_AUTH; echo '#endif') | \
+					(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+					grep HAS_AUTH >/dev/null
+				then
+					UNAME_PROCESSOR="arm64e"
+				else
+					UNAME_PROCESSOR="arm64"
+				fi
+			fi
+		fi ;;
 	    unknown) UNAME_PROCESSOR=powerpc ;;
 	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
