diff --git a/configure.ac b/configure.ac index 7066849c1eb75..ca81784a227db 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,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 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