From 992cf8c97cc71d4ca9a0a11e6604a6716ed4cefc Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Fri, 29 Jul 2022 19:34:00 +0300 Subject: [PATCH] Define __cpuid{ex} only when there's no builtin one (#73065) * Define __cpuid{ex} only when there's no builtin one Fix clang 15 RC1 build: `error: definition of builtin function '__cpuid'` * Add clang-15 autodetection --- eng/common/native/find-native-compiler.sh | 2 +- src/coreclr/vm/amd64/unixstubs.cpp | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/native/find-native-compiler.sh b/eng/common/native/find-native-compiler.sh index 4b99a9cad3b77..41a26d802a93f 100644 --- a/eng/common/native/find-native-compiler.sh +++ b/eng/common/native/find-native-compiler.sh @@ -55,7 +55,7 @@ # Set default versions if [ -z "$majorVersion" ]; then # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. - if [ "$compiler" = "clang" ]; then versions=( 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) + if [[ "$compiler" == "clang" ]]; then versions=( 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) elif [ "$compiler" = "gcc" ]; then versions=( 9 8 7 6 5 4.9 ); fi for version in "${versions[@]}"; do diff --git a/src/coreclr/vm/amd64/unixstubs.cpp b/src/coreclr/vm/amd64/unixstubs.cpp index 517eea98f6b6a..09d2568a9273b 100644 --- a/src/coreclr/vm/amd64/unixstubs.cpp +++ b/src/coreclr/vm/amd64/unixstubs.cpp @@ -10,6 +10,7 @@ extern "C" PORTABILITY_ASSERT("Implement for PAL"); } +#if !__has_builtin(__cpuid) void __cpuid(int cpuInfo[4], int function_id) { // Based on the Clang implementation provided in cpuid.h: @@ -20,7 +21,9 @@ extern "C" : "0"(function_id) ); } +#endif +#if !__has_builtin(__cpuidex) void __cpuidex(int cpuInfo[4], int function_id, int subFunction_id) { // Based on the Clang implementation provided in cpuid.h: @@ -31,6 +34,7 @@ extern "C" : "0"(function_id), "2"(subFunction_id) ); } +#endif DWORD xmmYmmStateSupport() {