Skip to content

Commit ed618c1

Browse files
committed
Add -Wno-implicit-fallthrough flags conditionally
Older GCC versions (> 7.0) don't support the -Wno-implicit-fallthrough compiler flag. This adds the flag conditionally in case some other compiler will run into same issue. Fixes #13330
1 parent 7096eff commit ed618c1

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

ext/date/config0.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ AC_CHECK_HEADERS([io.h])
44
dnl Check for strtoll, atoll
55
AC_CHECK_FUNCS(strtoll atoll)
66

7-
PHP_DATE_CFLAGS="-Wno-implicit-fallthrough -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1"
7+
AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], [PHP_DATE_CFLAGS="$PHP_DATE_CFLAGS -Wno-implicit-fallthrough"],,[-Werror])
8+
9+
PHP_DATE_CFLAGS="$PHP_DATE_CFLAGS -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1"
810
timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/parse_posix.c
911
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c"
1012

ext/hash/config.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ else
2828
SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-opt64.c"
2929
])
3030
EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c hash_sha3.c"
31+
3132
dnl Add -Wno-implicit-fallthrough flag as it happens on 32 bit builds
32-
PHP_HASH_CFLAGS="-Wno-implicit-fallthrough -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
33+
AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], [PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -Wno-implicit-fallthrough"],,[-Werror])
34+
35+
PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
3336

3437
PHP_ADD_BUILD_DIR(ext/hash/$SHA3_DIR, 1)
3538
fi

ext/opcache/config.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ int main() {
313313
fi
314314
AC_MSG_RESULT([$have_shm_mmap_posix])
315315

316+
AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], [PHP_OPCACHE_CFLAGS="$PHP_OPCACHE_CFLAGS -Wno-implicit-fallthrough"],,[-Werror])
317+
316318
PHP_NEW_EXTENSION(opcache,
317319
ZendAccelerator.c \
318320
zend_accelerator_blacklist.c \
@@ -328,7 +330,7 @@ int main() {
328330
shared_alloc_mmap.c \
329331
shared_alloc_posix.c \
330332
$ZEND_JIT_SRC,
331-
shared,,"-Wno-implicit-fallthrough -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1",,yes)
333+
shared,,"$PHP_OPCACHE_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1",,yes)
332334

333335
PHP_ADD_EXTENSION_DEP(opcache, pcre)
334336

ext/pcre/config0.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ else
6666
pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c pcre2lib/pcre2_substring.c \
6767
pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
6868
pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c pcre2lib/pcre2_script_run.c"
69-
PHP_PCRE_CFLAGS="-Wno-implicit-fallthrough -DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
69+
70+
AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], [PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -Wno-implicit-fallthrough"],,[-Werror])
71+
72+
PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
7073
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
7174
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
7275

0 commit comments

Comments
 (0)