Skip to content

Commit

Permalink
Merge branch 'PHP-8.3'
Browse files Browse the repository at this point in the history
* PHP-8.3:
  Do not remove -O0 in the middle of a flag
  Fix removal of optimization cflags in debug builds (php#9647)
  • Loading branch information
arnaud-lb committed Sep 12, 2024
2 parents 66060b1 + be1bf3f commit c21899a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 12 additions & 0 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2533,3 +2533,15 @@ AS_VAR_IF([php_var], [yes],
[Define to 1 if the compiler supports the '$1' variable attribute.])])
AS_VAR_POPDEF([php_var])
])

dnl
dnl PHP_REMOVE_OPTIMIZATION_FLAGS
dnl
dnl Removes known compiler optimization flags like -O, -O0, -O1, ..., -Ofast
dnl from CFLAGS and CXXFLAGS.
dnl
AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
sed_script='s/\([[\t ]]\|^\)-O\([[0-9gsz]]\|fast\|\)\([[\t ]]\|$\)/\1/g'
CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
])
12 changes: 2 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,7 @@ AS_VAR_IF([PHP_GCOV], [yes], [
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/build/Makefile.gcov], [$abs_srcdir])
dnl Remove all optimization flags from CFLAGS.
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([,])
PHP_REMOVE_OPTIMIZATION_FLAGS
dnl Add the special gcc flags.
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
Expand All @@ -806,11 +802,7 @@ PHP_ARG_ENABLE([debug],
AS_VAR_IF([PHP_DEBUG], [yes], [
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([,])
PHP_REMOVE_OPTIMIZATION_FLAGS
dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0"
Expand Down
6 changes: 1 addition & 5 deletions scripts/phpize.m4
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ dnl Discard optimization flags when debugging is enabled.
AS_VAR_IF([PHP_DEBUG], [yes], [
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([,])
PHP_REMOVE_OPTIMIZATION_FLAGS
dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0"
Expand Down

0 comments on commit c21899a

Please sign in to comment.