Commit 355571cefdf for php.net

commit 355571cefdf4263bc668cb8f1e71ad00ce890c43
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date:   Tue Apr 21 18:08:01 2026 +0200

    Fix usage of optimize attribute on unsupported compilers (GH-21819)

    Clang supports __has_attribute(cold) but not __attribute__((optimize(...))). The cold and optimize branches need to be split.

diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 6801131e41d..cd26aa17471 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -314,15 +314,14 @@ char *alloca();

 #if (defined(__GNUC__) && ZEND_GCC_VERSION >= 4003) || __has_attribute(cold)
 # define ZEND_COLD __attribute__((cold))
-# ifdef __OPTIMIZE__
-#  define ZEND_OPT_SIZE  __attribute__((optimize("Os")))
-#  define ZEND_OPT_SPEED __attribute__((optimize("Ofast")))
-# else
-#  define ZEND_OPT_SIZE
-#  define ZEND_OPT_SPEED
-# endif
 #else
 # define ZEND_COLD
+#endif
+
+#if ((defined(__GNUC__) && ZEND_GCC_VERSION >= 4003) || __has_attribute(optimize)) && defined(__OPTIMIZE__)
+# define ZEND_OPT_SIZE  __attribute__((optimize("Os")))
+# define ZEND_OPT_SPEED __attribute__((optimize("Ofast")))
+#else
 # define ZEND_OPT_SIZE
 # define ZEND_OPT_SPEED
 #endif