From 573be0228778873c0d445263fb09989918bea4c1 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Tue, 1 Mar 2022 15:35:07 -0700 Subject: [PATCH] cf: Use -Werror when checking for -Wno-* flags When detecting valid compiler flags clang behaves differently than gcc for certain types of flags. Specifically, gcc will ignore an unknown "-Wno-someflag" while clang will issue a warning. If using clang and --enable-checking is specified, this difference causes a build failure because the warning for the unknown flag is turned into an error. The autoconf macro AX_APPEND_COMPILE_FLAGS (via the underlying macro AX_CHECK_COMPILE_FLAGS) looks specifically for errors and not warnings to determine if the flag is valid. In order to properly catch the above type of unknown compiler flags, a '-Werror' must be passed as an extra-flag. Update the autoconf functions that use AX_APPEND_COMPILE_FLAGS to use '-Werror' as an extra flag when testing for "-Wno-..." flags. Note, for gcc, the test may (incorrectly) think that the compiler supports the given flag, but that is okay, since the flag will be ignored by gcc during the build without raising any warnings or errors. Change-Id: I9e4dabf04a3b019cb1ea58a4b2ac1cf0fc8d1e71 Reviewed-on: https://gerrit.openafs.org/14900 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- src/cf/linux-checks.m4 | 2 +- src/cf/osconf.m4 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cf/linux-checks.m4 b/src/cf/linux-checks.m4 index f0d2dafeb5..e5dcdcc1ed 100644 --- a/src/cf/linux-checks.m4 +++ b/src/cf/linux-checks.m4 @@ -16,7 +16,7 @@ if test "x$enable_debug_kernel" = "xno"; then fi AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -fno-strength-reduce \ -fno-common -pipe], - [LINUX_GCC_KOPTS]) + [LINUX_GCC_KOPTS],[-Werror]) AC_SUBST(LINUX_GCC_KOPTS) dnl Setup the kernel build environment diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index d98a1fe2bd..2805ab604e 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -645,9 +645,9 @@ if test "x$GCC" = "xyes"; then CFLAGS_NOUNUSED="-Wno-unused" CFLAGS_NOOLDSTYLE="-Wno-old-style-definition" AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough], - [CFLAGS_NOIMPLICIT_FALLTHROUGH]) + [CFLAGS_NOIMPLICIT_FALLTHROUGH], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wno-cast-function-type], - [CFLAGS_NOCAST_FUNCTION_TYPE]) + [CFLAGS_NOCAST_FUNCTION_TYPE], [-Werror]) AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode]) else CFLAGS_NOSTRICT= @@ -673,7 +673,7 @@ fi dnl add additional checks if compilers support the flags AS_IF([test "x$enable_checking" != "xno"], - [AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS]) + [AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS], [-Werror]) ]) dnl horribly cheating, assuming double / is ok.