[linux-nfc] [neard][PATCH v2 70/73] build: enable -Wunsafe-loop-optimizations and -Wstrict-overflow=2 warnings
Krzysztof Kozlowski <[email protected]> Mon, 19 Jul 2021 13:08:16 +0200
| Newsgroups | org.01.lists.linux-nfc,dev.linux.lists.oe-linux-nfc |
|---|---|
| Message-ID | <[email protected]> |
Enable basic overflow in optimization checks (portability related) and missed loop optimizations. The latter (-Wunsafe-loop-optimizations) does not work well with GCC v7.5 so simply skip it there. Signed-off-by: Krzysztof Kozlowski <[email protected]> --- accflags.m4 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/accflags.m4 b/accflags.m4 index 57cc48beecc2..0030ac339c86 100644 --- a/accflags.m4 +++ b/accflags.m4 @@ -24,6 +24,7 @@ AC_DEFUN([NEARD_COMPILER_FLAGS], [ AX_CHECK_COMPILE_FLAG([-Wjump-misses-init], [CFLAGS="$CFLAGS -Wjump-misses-init"]) AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"]) AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"]) + AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=2], [CFLAGS="$CFLAGS -Wstrict-overflow=2"]) # GCC v5.0 AX_CHECK_COMPILE_FLAG([-Wformat-signedness], [CFLAGS="$CFLAGS -Wformat-signedness"]) @@ -36,10 +37,16 @@ AC_DEFUN([NEARD_COMPILER_FLAGS], [ AX_CHECK_COMPILE_FLAG([-Walloc-zero], [CFLAGS="$CFLAGS -Walloc-zero"]) # GCC v8.0 AX_CHECK_COMPILE_FLAG([-Wstringop-truncation], [CFLAGS="$CFLAGS -Wstringop-truncation"]) + + # GCC v7.5 from Ubuntu Bionic incorrectly assumes several loops can overflow, so enable + # -Wunsafe-loop-optimizations only on newer GCC. + CC_VERSION=`$CC --version | head -n 1 | sed -e 's/.*\ \(@<:@0-9@:>@\+\.@<:@0-9@:>@\+\.@<:@0-9@:>@\+\)\(-@<:@0-9@:>@\+\)\?$/\1/'` + AX_COMPARE_VERSION([$CC_VERSION],[ge],[8.0.0], + [AX_CHECK_COMPILE_FLAG([-Wunsafe-loop-optimizations], [CFLAGS="$CFLAGS -Wunsafe-loop-optimizations"])], []) fi if (test "$USE_MAINTAINER_MODE" = "pedantic"); then - AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=3], [CFLAGS="$CFLAGS -Wstrict-overflow=3"]) AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"]) - AX_CHECK_COMPILE_FLAG([-Wunsafe-loop-optimizations], [CFLAGS="$CFLAGS -Wunsafe-loop-optimizations"]) + # Instead of -Wstrict-overflow=2 + AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=3], [CFLAGS="$CFLAGS -Wstrict-overflow=3"]) fi ]) -- 2.27.0 _______________________________________________ Linux-nfc mailing list -- [email protected] To unsubscribe send an email to [email protected] %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s