-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cmake: use TargetConditionals.h for SIMD testing on Apple #12731
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
base: main
Are you sure you want to change the base?
Conversation
expands to <nothing> on e.g. Windows, which will be interpreted as true by cmake_dependent_option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked OK to be after brief eyeballing.
This actions run behaves as expected now: https://github.com/libsdl-org/SDL/actions/runs/14251280259/job/39944568381?pr=12731
|
An Apple person should check whether the --- a/include/SDL3/SDL_intrin.h
+++ b/include/SDL3/SDL_intrin.h
@@ -356,7 +356,11 @@ _m_prefetch(void *__P)
# endif
#endif
-#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
+#ifdef __APPLE__
+#include "TargetConditionals.h"
+#endif
+
+#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || (defined(TARGET_CPU_X86) && TARGET_CPU_X86) || (defined(TARGET_CPU_X86_64) && TARGET_CPU_X86_64)
# if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
# define SDL_MMX_INTRINSICS 1
# include <mmintrin.h> |
I don't think this is necessary: TARGET_CPU_X86, for, e.g., is defined to 1 if |
be99236
to
7c9a6c9
Compare
I think we're fine. After thinking about it, CMake was failing because we were including |
# if test_enabled | ||
${MAIN_BODY} | ||
# endif | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading this correctly, this x86 test will succeed for aarch64-apple (non-x86.) Similarly, the arm test below will succeed for x86_64-apple (non-arm.) Is this what you really intend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions will only get called if cmake is targeting x64/x86.
I'll add a fail-safe that returns false when the cpu is not x86 (and vice verse for the arm function)
I think
include/SDL3/SDL_intrin.h
should get a similar makeover.