Skip to content

Commit 182fee1

Browse files
authored
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 c4d9a37 commit 182fee1

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
@@ -840,8 +840,9 @@ if test "$PHP_GCOV" = "yes"; then
840840

841841
dnl Remove all optimization flags from CFLAGS.
842842
changequote({,})
843-
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
844-
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
843+
dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
844+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
845+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
845846
changequote([,])
846847

847848
dnl Add the special gcc flags.
@@ -860,8 +861,9 @@ if test "$PHP_DEBUG" = "yes"; then
860861
PHP_DEBUG=1
861862
ZEND_DEBUG=yes
862863
changequote({,})
863-
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
864-
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
864+
dnl Discard known '-O...' flags, including just '-O', but do not remove only '-O' in '-Ounknown'
865+
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
866+
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O\([0-9gsz]\|fast\|\)\([\t ]\|$\)//g'`
865867
changequote([,])
866868
dnl Add -O0 only if GCC or ICC is used.
867869
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)