Skip to content

Fix build on Apple Clang 17+ #18629

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

Merged
merged 2 commits into from
May 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Zend/zend_cpuinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,58 +126,86 @@ ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
* functions */
ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse2(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
Copy link
Member

@nielsdos nielsdos May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking for __aarch64__ should be enough and is simpler

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although ideally we would use an allowlust rather than a denylist but that requires knowing what cpu we build for for sure and not all compilers set it the same way

return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse2");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse3(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse3");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_ssse3(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("ssse3");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse41(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.1");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_sse42(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("sse4.2");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx");
#endif
}

ZEND_NO_SANITIZE_ADDRESS
static inline int zend_cpu_supports_avx2(void) {
#if (defined(__APPLE__) && defined(__aarch64__) && defined(__clang_major__) && __clang_major__ >= 17)
return 0;
#else
#if PHP_HAVE_BUILTIN_CPU_INIT
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx2");
#endif
}

#if PHP_HAVE_AVX512_SUPPORTS
Expand Down
Loading