Skip to content

Commit

Permalink
Autotools: Refactor PHP_BROKEN_GCC_STRLEN_OPT (#14824)
Browse files Browse the repository at this point in the history
- Synced CS
- Cache variable ac_cv_have_broken_gcc_strlen_opt renamed to
  php_cv_have_broken_gcc_strlen_opt
  • Loading branch information
petk authored Jul 5, 2024
1 parent dccc911 commit ae42053
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
23 changes: 10 additions & 13 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1284,9 +1284,10 @@ dnl
dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they
dnl didn't properly handle the `char val[1]` struct hack. See bug #76510.
dnl
AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT], [
AC_CACHE_CHECK([for broken gcc optimize-strlen],ac_cv_have_broken_gcc_strlen_opt,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
AC_DEFUN([PHP_BROKEN_GCC_STRLEN_OPT],
[AC_CACHE_CHECK([for broken gcc optimize-strlen],
[php_cv_have_broken_gcc_strlen_opt],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Expand All @@ -1302,16 +1303,12 @@ int main(void)
strcpy(s->c, "foo");
return strlen(s->c+1) == 2;
}
]])],[
ac_cv_have_broken_gcc_strlen_opt=yes
],[
ac_cv_have_broken_gcc_strlen_opt=no
],[
ac_cv_have_broken_gcc_strlen_opt=no
])])
if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then
CFLAGS="$CFLAGS -fno-optimize-strlen"
fi
]])],
[php_cv_have_broken_gcc_strlen_opt=yes],
[php_cv_have_broken_gcc_strlen_opt=no],
[php_cv_have_broken_gcc_strlen_opt=no])])
AS_VAR_IF([php_cv_have_broken_gcc_strlen_opt], [yes],
[AS_VAR_APPEND([CFLAGS], [" -fno-optimize-strlen"])])
])

dnl
Expand Down
4 changes: 1 addition & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,7 @@ AC_CHECK_HEADERS(m4_normalize([

PHP_FOPENCOOKIE
PHP_BROKEN_GETCWD
if test "$GCC" = "yes"; then
PHP_BROKEN_GCC_STRLEN_OPT
fi
AS_VAR_IF([GCC], [yes], [PHP_BROKEN_GCC_STRLEN_OPT])

dnl Detect the headers required to use makedev, major, and minor.
dnl Autoconf <= 2.69 didn't check glibc 2.25 deprecated macros in sys/types.h.
Expand Down

0 comments on commit ae42053

Please sign in to comment.