File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1739,6 +1739,42 @@ choke me
17391739 fi
17401740] )
17411741
1742+ dnl
1743+ dnl PHP_BROKEN_GCC_STRLEN_OPT
1744+ dnl
1745+ dnl Early releases of GCC 8 shipped with a strlen() optimization bug, so they
1746+ dnl didn't properly handle the `char val[1]` struct hack. See bug #76510.
1747+ dnl
1748+ AC_DEFUN ( [ PHP_BROKEN_GCC_STRLEN_OPT] , [
1749+ AC_CACHE_CHECK ( [ for broken gcc optimize-strlen] ,ac_cv_have_broken_gcc_strlen_opt ,[
1750+ AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [ [
1751+ #include <stdlib.h>
1752+ #include <string.h>
1753+ #include <stdio.h>
1754+ struct s
1755+ {
1756+ int i;
1757+ char c[ 1] ;
1758+ };
1759+ int main()
1760+ {
1761+ struct s *s = malloc(sizeof(struct s) + 3);
1762+ s->i = 3;
1763+ strcpy(s->c, "foo");
1764+ return strlen(s->c+1) == 2;
1765+ }
1766+ ] ] ) ] ,[
1767+ ac_cv_have_broken_gcc_strlen_opt=yes
1768+ ] ,[
1769+ ac_cv_have_broken_gcc_strlen_opt=no
1770+ ] ,[
1771+ ac_cv_have_broken_gcc_strlen_opt=no
1772+ ] ) ] )
1773+ if test "$ac_cv_have_broken_gcc_strlen_opt" = "yes"; then
1774+ CFLAGS="$CFLAGS -fno-optimize-strlen"
1775+ fi
1776+ ] )
1777+
17421778dnl
17431779dnl PHP_FOPENCOOKIE
17441780dnl
Original file line number Diff line number Diff line change @@ -500,6 +500,9 @@ immintrin.h
500500PHP_FOPENCOOKIE
501501PHP_BROKEN_GETCWD
502502PHP_BROKEN_GLIBC_FOPEN_APPEND
503+ if test "$GCC" = "yes"; then
504+ PHP_BROKEN_GCC_STRLEN_OPT
505+ fi
503506
504507dnl Checks for typedefs, structures, and compiler characteristics.
505508dnl -------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments