From 8068c80e38ed8234f761cdd80c6c95ebc6c74b90 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 21 Apr 2026 14:58:41 +0200 Subject: [PATCH] Fix usage of optimize attribute on unsupported compilers The cold and optimize branches need to be split. --- Zend/zend_portability.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 6801131e41da..cd26aa174712 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