check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION#21622
Open
henderkes wants to merge 2 commits intophp:masterfrom
Open
check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION#21622henderkes wants to merge 2 commits intophp:masterfrom
henderkes wants to merge 2 commits intophp:masterfrom
Conversation
139ad97 to
99c5aa3
Compare
henderkes
commented
Apr 3, 2026
|
|
||
| /* __builtin_cpu_supports has pclmul from gcc9 */ | ||
| #if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000)) | ||
| #if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && (!defined(__GNUC__) || defined(__clang__) || (ZEND_GCC_VERSION >= 9000)) |
Contributor
Author
There was a problem hiding this comment.
this has existed in clang since basically forever, I went back all the way to version 5 and it's supported there
arnaud-lb
reviewed
Apr 3, 2026
| } align_test; | ||
|
|
||
| #if ZEND_GCC_VERSION >= 2000 | ||
| #if ZEND_GCC_VERSION >= 2000 || defined(__clang__) |
Member
There was a problem hiding this comment.
Possibly for a follow-up, but we could define C23's alignof in zend_portability.h, and then use it here:
#if !defined(alignof)
# if ZEND_GCC_VERSION >= 2000 || defined(__clang__)
# define alignof(x) __alignof__(x)
# endif
#endif
Contributor
Author
There was a problem hiding this comment.
What if we use MSVC to compile and aren't in C23 mode? It won't be defined at all, so we couldn't use it directly. I think that's for a follow up PR.
Member
There was a problem hiding this comment.
Yes you would still need an #ifdef alignof
…plicate lengthy #if checks
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.
initially found this for ZEND_COLD and then took a quick ctrl + shift + f for
ZEND_GCC_VERSION >=