From 41cdce32faf85d615628079e92d8e28c1c3aca09 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 30 Sep 2022 15:43:00 +0200 Subject: [PATCH 1/3] Discard known '-O' flags, but not just '-O' in '-Ounknown' --- scripts/phpize.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/phpize.m4 b/scripts/phpize.m4 index 616d16420a5a1..14bcde45f03a3 100644 --- a/scripts/phpize.m4 +++ b/scripts/phpize.m4 @@ -116,8 +116,9 @@ if test "$PHP_DEBUG" = "yes"; then PHP_DEBUG=1 ZEND_DEBUG=yes changequote({,}) - CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'` - CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'` + dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown' + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` + CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` changequote([,]) dnl Add -O0 only if GCC or ICC is used. if test "$GCC" = "yes" || test "$ICC" = "yes"; then From d992f62b79036227aab094a9b5149a9519ccb77b Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 20 Jan 2023 13:11:15 +0100 Subject: [PATCH 2/3] Fix removal of `-O` flag in more places --- configure.ac | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7066849c1eb75..bc2b41780d226 100644 --- a/configure.ac +++ b/configure.ac @@ -794,8 +794,9 @@ if test "$PHP_GCOV" = "yes"; then dnl Remove all optimization flags from CFLAGS. changequote({,}) - CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'` - CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'` + dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown' + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` + CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` changequote([,]) dnl Add the special gcc flags. @@ -814,8 +815,8 @@ if test "$PHP_DEBUG" = "yes"; then PHP_DEBUG=1 ZEND_DEBUG=yes changequote({,}) - CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'` - CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'` + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` + CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` changequote([,]) dnl Add -O0 only if GCC or ICC is used. if test "$GCC" = "yes" || test "$ICC" = "yes"; then From 2698f3064e3d0ffe128d5d843b649ce376a397ab Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 20 Jan 2023 13:13:30 +0100 Subject: [PATCH 3/3] Comment --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index bc2b41780d226..ca81784a227db 100644 --- a/configure.ac +++ b/configure.ac @@ -815,6 +815,7 @@ if test "$PHP_DEBUG" = "yes"; then PHP_DEBUG=1 ZEND_DEBUG=yes changequote({,}) + dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown' CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'` changequote([,])