11#[=============================================================================[
2- Early releases of GCC 8 shipped with a strlen() optimization bug, so they didn't
3- properly handle the 'char val[1]' struct hack. See https://bugs.php.net/76510.
4- If check is successful the -fno-optimize-strlen compiler flag should be used.
2+ GCC 8.2 shipped with a strlen() optimization bug, so it didn't properly handle
3+ the 'char val[1]' struct hack. Fixed in GCC 8.3. See https://bugs.php.net/76510
4+ and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86914. If below check is
5+ successful the -fno-optimize-strlen compiler flag should be used.
56
67Cache variables:
78
8- HAVE_BROKEN_OPTIMIZE_STRLEN
9- Whether GCC's optimize-strlen is broken.
9+ PHP_HAVE_BROKEN_OPTIMIZE_STRLEN
10+ Whether GCC has broken strlen() optimization .
1011]=============================================================================]#
1112
1213include_guard (GLOBAL )
1314
1415include (CheckSourceRuns)
1516include (CMakePushCheckState)
1617
17- if (NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" )
18+ if (
19+ NOT CMAKE_C_COMPILER_ID STREQUAL "GNU"
20+ OR (
21+ CMAKE_C_COMPILER_ID STREQUAL "GNU"
22+ AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.3
23+ )
24+ )
1825 return ()
1926endif ()
2027
21- message (CHECK_START "Checking for broken GCC optimize- strlen" )
28+ message (CHECK_START "Checking if GCC has broken strlen() optimization " )
2229
2330cmake_push_check_state(RESET)
2431 set (CMAKE_REQUIRED_QUIET TRUE )
@@ -41,10 +48,10 @@ cmake_push_check_state(RESET)
4148
4249 return strlen(s->c+1) == 2;
4350 }
44- ]] HAVE_BROKEN_OPTIMIZE_STRLEN )
51+ ]] PHP_HAVE_BROKEN_OPTIMIZE_STRLEN )
4552cmake_pop_check_state()
4653
47- if (HAVE_BROKEN_OPTIMIZE_STRLEN )
54+ if (PHP_HAVE_BROKEN_OPTIMIZE_STRLEN )
4855 message (CHECK_PASS "yes" )
4956else ()
5057 message (CHECK_FAIL "no" )
0 commit comments