Skip including cpuid.h under Windows with Clang-cl#296
Open
ericstone93 wants to merge 2 commits intomicrosoft:mainfrom
Open
Skip including cpuid.h under Windows with Clang-cl#296ericstone93 wants to merge 2 commits intomicrosoft:mainfrom
ericstone93 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Member
|
@Andrew-Farrier I recall we specifically used cpuid.h instead of intrin.h for DirectXMath 3.14. IIRC, the intrin.h approach resulted in bad codegen on clang for Windows. Do you remember the bug? Any way we can verify if it's fixed in newer clang compilers (the issue dates back to the Windows SDK (19041) timeframe). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The issue is it includes
<cpuid.h>when__clang__is defined and__x86_64__is set, but NOT on MinGW. This is the standard DirectXMath header from the Windows SDK.On Linux/Mac with Clang,
<cpuid.h>is a Clang/GCC built-in header that provides__cpuidand__cpuidexintrinsics. But on Windows with Clang-cl, those intrinsics come from<intrin.h>instead (which is already included on line 118 for_MSC_VER).Since Clang-cl defines both
__clang__AND_MSC_VER, it hits both the<intrin.h>include (good) AND the<cpuid.h>include (bad, doesn't exist on Windows). The fix is to exclude_MSC_VERas in the PR.Change
Add
!defined(_MSC_VER)to the<cpuid.h>include condition so it only applies to non-MSVC-compatible Clang/GCC on Linux/Mac x86 targets.