From 52c487a0e4432269b0b0ddc034155a8cf62e0299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=9C=B4=E5=AE=87?= Date: Wed, 5 Feb 2020 00:47:38 +0800 Subject: [PATCH] Use -Werror to check if the compiler supports specific options Be default, clang treats unknown warning option as warning. We need to use -Werror to make it an error. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: 12101111 Closes #9927 --- config/always-compiler-options.m4 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 index e187f6ff8..f903655fa 100644 --- a/config/always-compiler-options.m4 +++ b/config/always-compiler-options.m4 @@ -22,7 +22,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_ASAN], [ AS_IF([ test "$enable_asan" = "yes" ], [ AC_MSG_CHECKING([whether $CC supports -fsanitize=address]) saved_cflags="$CFLAGS" - CFLAGS="$CFLAGS -fsanitize=address" + CFLAGS="$CFLAGS -Werror -fsanitize=address" AC_LINK_IFELSE([ AC_LANG_SOURCE([[ int main() { return 0; } ]]) ], [ @@ -52,7 +52,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN], [ AC_MSG_CHECKING([whether $CC supports -Wframe-larger-than=]) saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wframe-larger-than=4096" + CFLAGS="$CFLAGS -Werror -Wframe-larger-than=4096" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ FRAME_LARGER_THAN="-Wframe-larger-than=4096" @@ -73,7 +73,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION], [ AC_MSG_CHECKING([whether $CC supports -Wno-format-truncation]) saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wno-format-truncation" + CFLAGS="$CFLAGS -Werror -Wno-format-truncation" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ NO_FORMAT_TRUNCATION=-Wno-format-truncation @@ -100,7 +100,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE], [ AC_MSG_CHECKING([whether $CC supports -Wno-bool-compare]) saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wbool-compare" + CFLAGS="$CFLAGS -Werror -Wbool-compare" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ NO_BOOL_COMPARE=-Wno-bool-compare @@ -126,7 +126,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE], [ AC_MSG_CHECKING([whether $CC supports -Wno-unused-but-set-variable]) saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wunused-but-set-variable" + CFLAGS="$CFLAGS -Werror -Wunused-but-set-variable" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable @@ -147,7 +147,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [ AC_MSG_CHECKING([whether $CC supports -fno-omit-frame-pointer]) saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -fno-omit-frame-pointer" + CFLAGS="$CFLAGS -Werror -fno-omit-frame-pointer" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ NO_OMIT_FRAME_POINTER=-fno-omit-frame-pointer