__cpuid and clang-cl
matbech opened this issue · comments
With clang-cl (15.0.4) using Clang Power Tools, I'm getting the following compiler error in XMVerifyCPUSupport:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.25276.0\um/DirectXMathMisc.inl:1977:5: error: no matching function for call to '__cpuid'
__cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
^~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.35.32019\include\intrin.h(191): message: candidate function not viable: requires 2 arguments, but 5 were provided
__MACHINEX86_X64(void __cpuid(int[4], int))
The problem is that with clang-cl, both __clang__
and _MSC_VER
are defined. And in this case intrin.h is included in DirectXMath.h (https://github.com/microsoft/DirectXMath/blob/main/Inc/DirectXMath.h#L117) and __cpuid
from this header should be used.
I see the problem now... You should not be using intrin.h
from the MSVC toolset when building with clang-cl. You should be using the intrin.h
that comes with your clang/LLVM.
While you can get it to "build" with the intrin.h from MSVC, it doesn't actually work at runtime and thus crashes.
Note that I specifically test clang/LLVM for Window as integrated into Visual Studio. I'm not sure what exactly Clang Power Tools is setting up.
Thank you for pointing this out. I will report the issue to Clang Power Tools.