From: Simon Marchi Date: Sat, 17 Jun 2017 21:18:20 +0000 (+0200) Subject: gdb: Use -Werror when checking for (un)supported warning flags X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e019bdc20eb81b91ab5bc774386201b874c0bac;p=binutils-gdb.git gdb: Use -Werror when checking for (un)supported warning flags In warning.m4, we pass all the warning flags one by one to the compiler to test if they are supported by this particular compiler. If the compiler exits with an error, we conclude that this warning flag is not supported and exclude it. This allows us to use warning flags without having to worry about which versions of which compilers support each flag. clang, by default, only emits a warning if an unknown flag is passed: warning: unknown warning option '-Wfoo' [-Wunknown-warning-option] The result is that we think that all the warning flags we use are supported by clang (they are not), and the compilation fails later when building with -Werror, since the aforementioned warning becomes an error. The fix is to also pass -Werror when probing for supported flags, then we'll correctly get an error when using an unknown warning, and we'll exclude it: error: unknown warning option '-Wfoo' [-Werror,-Wunknown-warning-option] I am not sure why there is a change in a random comment in gdbserver/configure, but I suppose it's a leftfover from a previous patch, so I included it. gdb/ChangeLog: * configure: Re-generate. * warning.m4: Pass -Werror to compiler when checking for supported warning flags. gdb/gdbserver/ChangeLog: * configure: Re-generate. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2c4f96e55d2..c14e2042578 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-06-17 Simon Marchi + + * configure: Re-generate. + * warning.m4: Pass -Werror to compiler when checking for + supported warning flags. + 2017-06-17 Simon Marchi * Makefile.in (COMPILE.pre): Add "-x c++". diff --git a/gdb/configure b/gdb/configure index 1f15d5d382e..df2747ad4fb 100755 --- a/gdb/configure +++ b/gdb/configure @@ -15222,9 +15222,9 @@ $as_echo_n "checking compiler warning flags... " >&6; } *) # Check whether GCC accepts it. saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wtest" + CFLAGS="$CFLAGS -Werror $wtest" saved_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $wtest" + CXXFLAGS="$CXXFLAGS -Werror $wtest" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index eef680cb347..2eb492ed9ad 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2017-06-17 Simon Marchi + + * configure: Re-generate. + 2017-06-17 Simon Marchi * Makefile.in (COMPILE.pre): Add "-x c++". diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index b314c417953..2550c7b14e5 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -7219,9 +7219,9 @@ $as_echo_n "checking compiler warning flags... " >&6; } *) # Check whether GCC accepts it. saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wtest" + CFLAGS="$CFLAGS -Werror $wtest" saved_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $wtest" + CXXFLAGS="$CXXFLAGS -Werror $wtest" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7498,9 +7498,9 @@ _ACEOF fi -# See if supports the %fs_base and %gs_base amd64 segment -# registers. Older amd64 Linux's don't have the fs_base and gs_base -# members of `struct user_regs_struct'. +# See if supports the %fs_base and %gs_bas amd64 segment registers. +# Older amd64 Linux's don't have the fs_base and gs_base members of +# `struct user_regs_struct'. ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include " if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then : diff --git a/gdb/warning.m4 b/gdb/warning.m4 index 98e745375eb..00e0f3899d7 100644 --- a/gdb/warning.m4 +++ b/gdb/warning.m4 @@ -103,9 +103,9 @@ then *) # Check whether GCC accepts it. saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wtest" + CFLAGS="$CFLAGS -Werror $wtest" saved_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $wtest" + CXXFLAGS="$CXXFLAGS -Werror $wtest" AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",) CFLAGS="$saved_CFLAGS" CXXFLAGS="$saved_CXXFLAGS"