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.
This commit is contained in:
Simon Marchi 2017-06-17 23:18:20 +02:00
parent cf0dd6f02c
commit 3e019bdc20
5 changed files with 19 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2017-06-17 Simon Marchi <simon.marchi@ericsson.com>
* configure: Re-generate.
* warning.m4: Pass -Werror to compiler when checking for
supported warning flags.
2017-06-17 Simon Marchi <simon.marchi@ericsson.com>
* Makefile.in (COMPILE.pre): Add "-x c++".

4
gdb/configure vendored
View File

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

View File

@ -1,3 +1,7 @@
2017-06-17 Simon Marchi <simon.marchi@ericsson.com>
* configure: Re-generate.
2017-06-17 Simon Marchi <simon.marchi@ericsson.com>
* Makefile.in (COMPILE.pre): Add "-x c++".

View File

@ -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 <sys/user.h> 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 <sys/user.h> 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 <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then :

View File

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