-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix use of undeclared identifier __cpuidex
error on MinGW
#92488
Conversation
For further clarification. The warning-to-error is not specific to |
Thanks for the research and the fix. Some comments:
diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
index d01eab3c9d..4c5495c2ce 100644
--- a/thirdparty/embree/common/sys/sysinfo.cpp
+++ b/thirdparty/embree/common/sys/sysinfo.cpp
@@ -293,11 +293,8 @@ namespace embree
int cpuid_leaf_7[4] = { 0,0,0,0 };
int cpuid_leaf_e1[4] = { 0,0,0,0 };
if (nIds >= 1) __cpuid (cpuid_leaf_1,0x00000001);
-#if _WIN32
-#if _MSC_VER && (_MSC_FULL_VER < 160040219)
-#else
+#if _MSC_VER && (_MSC_FULL_VER >= 160040219)
if (nIds >= 7) __cpuidex(cpuid_leaf_7,0x00000007,0);
-#endif
#else
if (nIds >= 7) __cpuid_count(cpuid_leaf_7,0x00000007,0);
#endif |
__cpuidex
error on MinGW
I will try and see if that works |
I can confirm that it does not like that. It errors with:
Anything else you would like me to try or should we leave it as is? Should I put a PR upstream to see if they have any feedback? |
Yes, please do. If they're reactive, they should point to the proper / best solution for their codebase. |
Perfect! Then we can replace our patch with their fix assuming its appropriate for our codebase as well :) |
Put in an upstream PR over here: RenderKit/embree#487 |
Could you also include the patch we made to thirdparty code as a patch file in the same commit? I.e.
This is how we document (and reapply on update) the downstream changes we made. |
@akien-mga Got distracted by some things on our game. I'll look into that this week. |
@akien-mga I added the patch file :) |
Thanks! |
This change requires the target to be
msvc
in order to reference the method__cpuidex
. The reasoning is due to a breaking change that appears to have come into effect recently across all major c / c++ compilers. Details are as follows:LLVM, Zig (which uses LLVM under the hood), and GCC all recently updated their compilers changing what was a warning to an error. The compiler will now error if attempting to reference
__cpuidex
and not targetting msvc. It will no longer work for MINGW targets.Here are relevant docs / source code for reference
Discovered by @Rexicon226, here is the LLVM code and how it handles it:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/BLAKE3/blake3_dispatch.c#L46-L60
Another helpful zig dev who's discord username is "random internet person" found: https://github.com/ziglang/zig/blob/master/lib/zig.h#L3902-L3913
Which appears similar to LLVM's new implementation.
And GNU posted a more formal announcement notifying of the warn to error change that appears to have propagated across all major compilers recently: https://gcc.gnu.org/gcc-14/porting_to.html#warnings-as-errors
Shoutout to @paperdave for all the help and guidance along the way! :)