Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Do not remove -O0 in the middle of a flag
  Fix removal of optimization cflags in debug builds (#9647)
This commit is contained in:
Arnaud Le Blanc 2024-09-12 13:11:49 +02:00
commit be1bf3f35e
No known key found for this signature in database
GPG key ID: 0098C05DD15ABC13
3 changed files with 15 additions and 12 deletions

View file

@ -2849,3 +2849,15 @@ AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS], AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS],
[$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI]) [$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI])
]) ])
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")
])

View file

@ -860,10 +860,7 @@ if test "$PHP_GCOV" = "yes"; then
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/build/Makefile.gcov, $abs_srcdir) PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/build/Makefile.gcov, $abs_srcdir)
dnl Remove all optimization flags from CFLAGS. dnl Remove all optimization flags from CFLAGS.
changequote({,}) PHP_REMOVE_OPTIMIZATION_FLAGS
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
changequote([,])
dnl Add the special gcc flags. dnl Add the special gcc flags.
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage" CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
@ -880,10 +877,7 @@ PHP_ARG_ENABLE([debug],
if test "$PHP_DEBUG" = "yes"; then if test "$PHP_DEBUG" = "yes"; then
PHP_DEBUG=1 PHP_DEBUG=1
ZEND_DEBUG=yes ZEND_DEBUG=yes
changequote({,}) PHP_REMOVE_OPTIMIZATION_FLAGS
CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
changequote([,])
dnl Add -O0 only if GCC or ICC is used. dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0" CFLAGS="$CFLAGS -O0"

View file

@ -115,10 +115,7 @@ dnl Discard optimization flags when debugging is enabled.
if test "$PHP_DEBUG" = "yes"; then if test "$PHP_DEBUG" = "yes"; then
PHP_DEBUG=1 PHP_DEBUG=1
ZEND_DEBUG=yes ZEND_DEBUG=yes
changequote({,}) PHP_REMOVE_OPTIMIZATION_FLAGS
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
changequote([,])
dnl Add -O0 only if GCC or ICC is used. dnl Add -O0 only if GCC or ICC is used.
if test "$GCC" = "yes" || test "$ICC" = "yes"; then if test "$GCC" = "yes" || test "$ICC" = "yes"; then
CFLAGS="$CFLAGS -O0" CFLAGS="$CFLAGS -O0"