[php-src] PHP-8.4: Backport fixes for macOS 26 (#24031)

From: Date: Fri, 02 Oct 2026 08:35:14 +0000
Subject: [php-src] PHP-8.4: Backport fixes for macOS 26 (#24031)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141861@lists.php.net to get a copy of this message
Author: Shivam Mathur (shivammathur) Committer: GitHub (web-flow) Pusher: shivammathur Date: 2026-10-02T14:05:05+05:30 Commit: https://github.com/php/php-src/commit/ef4fa59928110c66588610c1cf45c1bf86460122 Raw diff: https://github.com/php/php-src/commit/ef4fa59928110c66588610c1cf45c1bf86460122.diff Backport fixes for macOS 26 (#24031) * Fix -Wdefault-const-init-field-unsafe with clang 21 (#21135) Fixes the following warning: Zend/zend_alloc.c:3469:18: error: default initialization of an object of type 'zend_mm_storage' (aka 'struct _zend_mm_storage') with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe] 3469 | zend_mm_storage tmp_storage, *storage; | ^ Zend/zend_alloc.h:313:25: note: member 'handlers' declared 'const' here 313 | const zend_mm_handlers handlers; | ^ (cherry picked from commit 68a10628a2d6ed7d58bbe4e6dd670bee5c348233) * ext/standard: Use posix_spawn_file_actions_addchdir when available (#21553) posix_spawn_file_actions_addchdir is part of POSIX now, so some OSes (macOS at least) have started to deprecated the _np variant. Some support both names (Solaris, NetBSD), others don't yet (FreeBSD). Use the non-np variant when possible to avoid the deprecation warning on macOS and other platforms in the future. Fixes GH-21552 (cherry picked from commit c3a1214ef9975b537339196da6645ee9c5dc4667) * Fix GH-21720: macOS posix_spawn_file_actions_addchdir availability handling On Apple, select the addchdir variant by deployment target instead of the configure check: the link check passes whenever the SDK exports the symbol even if the running system is older, leaving a weakly linked reference that resolves to NULL at runtime and crashing proc_open() when $cwd is used. Closes GH-21722 (cherry picked from commit 8ce99bc2cec1bb3ff47b5569d573151395bf1fc6) * Fix compilation errors up until Clang 21.0 (#22141) - The "pclmul" and "cldemote" CPU features are both only available on x86, and the relevant __builtin_cpu_supports() checks fail on Clang, so they shouldn't even be attempted to be run (similar fixes before: https://github.com/php/php-src/pull/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. (cherry picked from commit a7aacec6f854e78a4688884de598b2e029b84f86) * zend: ZEND_NONSTRING for clang >= 20 support (#19193) (cherry picked from commit e91d2c719fc389edadc4ffbed59ab740a088b139) --------- Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com> Co-authored-by: Calvin Buckley <calvinb@php.net> Co-authored-by: arshidkv12 <arshidkv12@gmail.com> Co-authored-by: Máté Kocsis <kocsismate@woohoolabs.com> Co-authored-by: David CARLIER <devnexen@gmail.com> Changed paths: M Zend/zend_alloc.c M ext/dom/config.m4 M ext/fileinfo/libmagic/apprentice.c M ext/standard/config.m4 M ext/standard/proc_open.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index f057f4ad6221..7768d4e3af3d 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -3219,12 +3219,14 @@ ZEND_API zend_mm_heap *zend_mm_startup(void) ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size) { #if ZEND_MM_STORAGE - zend_mm_storage tmp_storage, *storage; + zend_mm_storage *storage; + zend_mm_storage tmp_storage = { + .handlers = *handlers, + .data = data, + }; zend_mm_chunk *chunk; zend_mm_heap *heap; - memcpy((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers)); - tmp_storage.data = data; chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE); if (UNEXPECTED(chunk == NULL)) { #if ZEND_MM_ERROR diff --git a/ext/dom/config.m4 b/ext/dom/config.m4 index f5f8a1cae8c4..5d09bee613e3 100644 --- a/ext/dom/config.m4 +++ b/ext/dom/config.m4 @@ -8,7 +8,7 @@ if test "$PHP_DOM" != "no"; then PHP_SETUP_LIBXML([DOM_SHARED_LIBADD], [ AC_DEFINE([HAVE_DOM], [1], [Define to 1 if the PHP extension 'dom' is available.]) - PHP_LEXBOR_CFLAGS="-I@ext_srcdir@/lexbor -DLEXBOR_STATIC" + PHP_LEXBOR_CFLAGS="-Wno-unknown-warning-option -Wno-unterminated-string-initialization -I@ext_srcdir@/lexbor -DLEXBOR_STATIC" LEXBOR_DIR="lexbor/lexbor" LEXBOR_SOURCES=m4_normalize([" $LEXBOR_DIR/core/array_obj.c diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index d7640e74a9db..87859bbdf898 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -184,7 +184,7 @@ file_private struct { { NULL, 0, NULL } }; -#if __has_attribute(nonstring) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 15 +#if __has_attribute(nonstring) && defined(__GNUC__) && ((!defined(__clang__) && __GNUC__ >= 15) || (defined(__clang_major__) && __clang_major__ >= 20)) # define ZEND_NONSTRING __attribute__((nonstring)) #else # define ZEND_NONSTRING diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index ef6b3c5a0101..1d64c7ff6968 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -328,7 +328,7 @@ dnl PHP_CHECK_FUNC(res_search, resolv, socket) -AC_CHECK_FUNCS([posix_spawn_file_actions_addchdir_np elf_aux_info]) +AC_CHECK_FUNCS([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np elf_aux_info]) dnl dnl Obsolete check for strptime() declaration. The strptime, where available, diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index bd4cf7a0a0ee..20f093f21839 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -35,7 +35,7 @@ #include <fcntl.h> #endif -#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP +#if defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP) || defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) /* Only defined on glibc >= 2.29, FreeBSD CURRENT, musl >= 1.1.24, * MacOS Catalina or later.. * It should be posible to modify this so it is also @@ -44,7 +44,24 @@ * to be really buggy. */ #include <spawn.h> +#ifdef __APPLE__ +#include <AvailabilityMacros.h> +#endif #define USE_POSIX_SPAWN + +/* The non-_np variant is in macOS 26 (and _np deprecated). On Apple, it has to be selected by the + * deployment target rather than the configure check: the link check passes whenever the SDK + * exports the symbol even if the running system is older, in which case the weakly linked + * reference resolves to NULL at runtime. */ +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir +#elif defined(__APPLE__) +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir +#else +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np +#endif #endif /* This symbol is defined in ext/standard/config.m4. @@ -1391,9 +1408,9 @@ PHP_FUNCTION(proc_open) } if (cwd) { - r = posix_spawn_file_actions_addchdir_np(&factions, cwd); + r = POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(&factions, cwd); if (r != 0) { - php_error_docref(NULL, E_WARNING, "posix_spawn_file_actions_addchdir_np() failed: %s", strerror(r)); + php_error_docref(NULL, E_WARNING, ZEND_TOSTR(POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) "() failed: %s", strerror(r)); } }

« previous php.cvs (#141861) next »