Skip to content

Commit 2e6745b

Browse files
committed
Fix compilation errors up until Clang 21.0
- The "pclmul" and "cldemote" CPU features are both only available on x86-64, and the __builtin_cpu_supports() checks in question fail on Clang, so they shouldn't even be tried to be run (similar fixes before: #18629). - The res.h file in Lexbor contains some unterminated strings (e.g. https://github.com/php/php-src/blob/d58d3d2fd6c1cfa7e3489a9859eda63086af762f/ext/lexbor/lexbor/html/tokenizer/res.h#L203), and a new compiler warning fails by default because of them. This needs to be suppressed.
1 parent 27d7b79 commit 2e6745b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Zend/zend_cpuinfo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ static zend_always_inline int zend_cpu_supports_avx512_vbmi(void) {
272272
#endif
273273

274274
/* __builtin_cpu_supports has pclmul from gcc9 and clang 19 */
275-
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && (!defined(__GNUC__) || (defined(__clang__) && __clang_major__ >= 19) || (ZEND_GCC_VERSION >= 9000))
275+
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(__x86_64__) && \
276+
( \
277+
(!defined(__GNUC__) || (defined(__clang__) && __clang_major__ >= 19) || (ZEND_GCC_VERSION >= 9000)) \
278+
)
276279
ZEND_NO_SANITIZE_ADDRESS
277280
static inline int zend_cpu_supports_pclmul(void) {
278281
#ifdef PHP_HAVE_BUILTIN_CPU_INIT
@@ -287,7 +290,11 @@ static inline int zend_cpu_supports_pclmul(void) {
287290
#endif
288291

289292
/* __builtin_cpu_supports has cldemote from gcc11 and clang 19 */
290-
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && ((defined(__clang__) && (__clang_major__ >= 19)) || (!defined(__clang__) && defined(__GNUC__) && (ZEND_GCC_VERSION >= 11000)))
293+
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(__x86_64__) && \
294+
( \
295+
(defined(__clang__) && (__clang_major__ >= 19)) || \
296+
(!defined(__clang__) && defined(__GNUC__) && (ZEND_GCC_VERSION >= 11000)) \
297+
)
291298
#define HAVE_ZEND_CPU_SUPPORTS_CLDEMOTE 1
292299
ZEND_NO_SANITIZE_ADDRESS
293300
static inline int zend_cpu_supports_cldemote(void) {

ext/lexbor/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PHP_LEXBOR_CFLAGS="-I@ext_srcdir@/"
1+
PHP_LEXBOR_CFLAGS="-Wno-unterminated-string-initialization -I@ext_srcdir@/"
22
LEXBOR_DIR="lexbor"
33

44
AC_DEFINE([HAVE_LEXBOR], [1], [Define to 1 if the PHP extension 'lexbor' is available.])

0 commit comments

Comments
 (0)