From 02a6fecb97de90c40c65417d613f29dd32d7209b Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 31 Dec 2025 00:26:34 +0100 Subject: [PATCH 1/2] Make preserve_none check lto compatible Fixes GH-20806 Closes GH-20810 --- Zend/Zend.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 33009e9909f5a..1e91450fcb947 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -487,7 +487,7 @@ uint64_t key = UINT64_C(0x9d7f71d2bd296364); uintptr_t _a = 0; uintptr_t _b = 0; -uintptr_t __attribute__((preserve_none)) fun(uintptr_t a, uintptr_t b) { +uintptr_t __attribute__((preserve_none,noinline,used)) fun(uintptr_t a, uintptr_t b) { _a = a; _b = b; return (uintptr_t)const3; @@ -568,6 +568,7 @@ int main(void) { [php_cv_preserve_none=no], [php_cv_preserve_none=no]) ]) + AC_MSG_RESULT([$php_cv_preserve_none]) AS_VAR_IF([php_cv_preserve_none], [yes], [ AC_DEFINE([HAVE_PRESERVE_NONE], [1], [Define to 1 if you have preserve_none support.]) From 95a83956a4b47a55baa8ef4638710511d30235fc Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 25 Dec 2025 08:23:39 +0000 Subject: [PATCH 2/2] Fix GH-20767: build failure with preserve_none attribute enabled on mac. Established that build < 1700.4.4.1 tends to fail thus we disable the preserve_none attribute feature for these cases. close GH-20777 --- NEWS | 6 +++++- Zend/zend_portability.h | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index c8ac6f1990cb4..ef10d7274a0b0 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,11 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.3 - +- Core: + . Fixed bug GH-20806 (preserve_none feature compatiblity with LTO). + (henderkes) + . Fixed bug GH-20767 (build failure with musttail/preserve_none feature + on macOs). (David Carlier) 15 Jan 2026, PHP 8.5.2 diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index c7e12d58c1f53..6546ebfb5b790 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -336,9 +336,12 @@ char *alloca(); # define ZEND_PRESERVE_NONE __attribute__((preserve_none)) #endif -#if __has_attribute(musttail) -# define HAVE_MUSTTAIL -# define ZEND_MUSTTAIL __attribute__((musttail)) + +#if !defined(__apple_build_version__) || (defined(__apple_build_version__) && __apple_build_version__ >= 17000404) +# if __has_attribute(musttail) +# define HAVE_MUSTTAIL +# define ZEND_MUSTTAIL __attribute__((musttail)) +# endif #endif #if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)