Skip to content

Commit 67d4c27

Browse files
committed
Fix removal of optimization cflags in debug builds (php#9647)
Discard known '-O' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
1 parent bcd1f23 commit 67d4c27

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

configure.ac

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,9 @@ if test "$PHP_GCOV" = "yes"; then
846846

847847
dnl Remove all optimization flags from CFLAGS.
848848
changequote({,})
849-
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
850-
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
849+
dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
850+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
851+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
851852
changequote([,])
852853

853854
dnl Add the special gcc flags.
@@ -866,8 +867,9 @@ if test "$PHP_DEBUG" = "yes"; then
866867
PHP_DEBUG=1
867868
ZEND_DEBUG=yes
868869
changequote({,})
869-
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
870-
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
870+
dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
871+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
872+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
871873
changequote([,])
872874
dnl Add -O0 only if GCC or ICC is used.
873875
if test "$GCC" = "yes" || test "$ICC" = "yes"; then

scripts/phpize.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ if test "$PHP_DEBUG" = "yes"; then
116116
PHP_DEBUG=1
117117
ZEND_DEBUG=yes
118118
changequote({,})
119-
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
120-
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
119+
dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
120+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
121+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
121122
changequote([,])
122123
dnl Add -O0 only if GCC or ICC is used.
123124
if test "$GCC" = "yes" || test "$ICC" = "yes"; then

0 commit comments

Comments
 (0)