diff --git a/configure.ac b/configure.ac index df86325e843..8d2cc116e05 100644 --- a/configure.ac +++ b/configure.ac @@ -840,8 +840,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. @@ -860,8 +861,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 468771de7a6..54fab5e01cb 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