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 <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Cheyenne Wills 2022-03-01 15:35:07 -07:00 committed by Benjamin Kaduk
parent 3ca92248f3
commit 573be02287
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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.