From de76d825dd0c666dc536f45e4ab73522fc4ece5d Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:09:01 +0300 Subject: [PATCH 1/2] Define __cpuid{ex} only when there's no builtin one Fix clang 15 RC1 build: `error: definition of builtin function '__cpuid'` --- src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp | 4 ++++ src/coreclr/vm/amd64/unixstubs.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp index 0c776a204dc57..506c645d71d24 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp @@ -1200,6 +1200,7 @@ extern "C" uint64_t PalGetCurrentThreadIdForLogging() #if defined(HOST_X86) || defined(HOST_AMD64) +#if !__has_builtin(__cpuid) REDHAWK_PALEXPORT void __cpuid(int cpuInfo[4], int function_id) { // Based on the Clang implementation provided in cpuid.h: @@ -1210,7 +1211,9 @@ REDHAWK_PALEXPORT void __cpuid(int cpuInfo[4], int function_id) : "0"(function_id) ); } +#endif +#if !__has_builtin(__cpuidex) REDHAWK_PALEXPORT void __cpuidex(int cpuInfo[4], int function_id, int subFunction_id) { // Based on the Clang implementation provided in cpuid.h: @@ -1221,6 +1224,7 @@ REDHAWK_PALEXPORT void __cpuidex(int cpuInfo[4], int function_id, int subFunctio : "0"(function_id), "2"(subFunction_id) ); } +#endif REDHAWK_PALEXPORT uint32_t REDHAWK_PALAPI xmmYmmStateSupport() { 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() { From 94a58bed21f6eaab0e4171df5038266efe931ae8 Mon Sep 17 00:00:00 2001 From: Adeel <3840695+am11@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:12:08 +0300 Subject: [PATCH 2/2] Add clang-15 autodetection --- eng/common/native/init-compiler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh index 4b99a9cad3b77..41a26d802a93f 100644 --- a/eng/common/native/init-compiler.sh +++ b/eng/common/native/init-compiler.sh @@ -71,7 +71,7 @@ if [[ -z "$CLR_CC" ]]; then # 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=( 14 13 12 11 10 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=( 12 11 10 9 8 7 6 5 4.9 ); fi for version in "${versions[@]}"; do