diff --git a/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c b/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c index 9075a687527..1ae435454f4 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c +++ b/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c @@ -28,6 +28,12 @@ #include #include +#if defined(_MSC_VER) && !defined(__clang__) +#define NO_INLINE __declspec(noinline) +#else +#define NO_INLINE __attribute__((noinline)) +#endif + #ifndef _WIN64 #include #else @@ -381,8 +387,10 @@ static void initialize_cpuinfo(CpuidInfo *_cpuid_info) } } -// ported from from vm_version_x86.hpp::feature_flags -static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_info) +// ported from from vm_version_x86.cpp::feature_flags +// NO_INLINE is necessary to avoid an unexpected behavior if compiling on Darwin +// with Apple clang version 15.0.0 (included in Xcode 15.0). +NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_info) { if (_cpuid_info->std_cpuid1_edx.bits.cmpxchg8 != 0) features->fCX8 = 1;