Autotools: Refactor PHP_BROKEN_GCC_STRLEN_OPT (#14824)

- Synced CS
- Cache variable ac_cv_have_broken_gcc_strlen_opt renamed to
  php_cv_have_broken_gcc_strlen_opt
This commit is contained in:
Peter Kokot 2024-07-05 10:37:49 +02:00 committed by GitHub
parent dccc911c04
commit ae420538d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 16 deletions

View File

@ -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>
@ -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

View File

@ -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.