Fix -Wno-unknown-warning support detection

Ref: https://sourceware.org/ml/gdb/2015-12/msg00024.html

We have code in configure.ac that tries to detect whether the compiler
supports each warning and suppress it if not, but that doesn't work
with "-Wno-" options, because gcc doesn't error out for
-Wno-unknown-warning unless other diagnostics are being produced.

See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html.

Handle this by checking whether -Wfoo works when we actually want
-Wno-foo.

gdb/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

	* configure.ac (compiler warning flags): When testing a
	-Wno-foo option, check whether -Wfoo works instead.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

	* configure.ac (compiler warning flags): When testing a
	-Wno-foo option, check whether -Wfoo works instead.
	* configure: Regenerate.
This commit is contained in:
Pedro Alves 2015-12-16 22:56:48 +00:00
parent a4e22a5df6
commit 7544db951a
6 changed files with 56 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2015-12-16 Pedro Alves <palves@redhat.com>
* configure.ac (compiler warning flags): When testing a
-Wno-foo option, check whether -Wfoo works instead.
* configure: Regenerate.
2015-12-16 Pedro Alves <palves@redhat.com>
* common/vec.h (vec_offset): New macro.

13
gdb/configure vendored
View File

@ -14376,14 +14376,23 @@ $as_echo_n "checking compiler warning flags... " >&6; }
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
for w in ${build_warnings}; do
# GCC does not complain about -Wno-unknown-warning. Invert
# and test -Wunknown-warning instead.
case $w in
-Wno-*)
wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
*)
wtest=$w ;;
esac
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
*)
# Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
CFLAGS="$CFLAGS $wtest"
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $w"
CXXFLAGS="$CXXFLAGS $wtest"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

View File

@ -2007,14 +2007,23 @@ then
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
for w in ${build_warnings}; do
# GCC does not complain about -Wno-unknown-warning. Invert
# and test -Wunknown-warning instead.
case $w in
-Wno-*)
wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
*)
wtest=$w ;;
esac
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
*)
# Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
CFLAGS="$CFLAGS $wtest"
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $w"
CXXFLAGS="$CXXFLAGS $wtest"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
CXXFLAGS="$saved_CXXFLAGS"

View File

@ -1,3 +1,9 @@
2015-12-16 Pedro Alves <palves@redhat.com>
* configure.ac (compiler warning flags): When testing a
-Wno-foo option, check whether -Wfoo works instead.
* configure: Regenerate.
2015-12-11 Don Breazeal <donb@codesourcery.com>
* server.c (process_serial_event): Don't exit from gdbserver

View File

@ -6148,14 +6148,23 @@ $as_echo_n "checking compiler warning flags... " >&6; }
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
for w in ${build_warnings}; do
# GCC does not complain about -Wno-unknown-warning. Invert
# and test -Wunknown-warning instead.
case $w in
-Wno-*)
wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
*)
wtest=$w ;;
esac
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
*)
# Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
CFLAGS="$CFLAGS $wtest"
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $w"
CXXFLAGS="$CXXFLAGS $wtest"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

View File

@ -193,14 +193,23 @@ then
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
for w in ${build_warnings}; do
# GCC does not complain about -Wno-unknown-warning. Invert
# and test -Wunknown-warning instead.
case $w in
-Wno-*)
wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
*)
wtest=$w ;;
esac
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
*)
# Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $w"
CFLAGS="$CFLAGS $wtest"
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $w"
CXXFLAGS="$CXXFLAGS $wtest"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
CXXFLAGS="$saved_CXXFLAGS"