* [PATCH] Fix -Wno-unknown-warning support detection
@ 2015-12-16 22:58 Pedro Alves
2015-12-16 23:07 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2015-12-16 22:58 UTC (permalink / raw)
To: gdb-patches
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.
---
gdb/configure | 13 +++++++++++--
gdb/configure.ac | 13 +++++++++++--
gdb/gdbserver/configure | 13 +++++++++++--
gdb/gdbserver/configure.ac | 13 +++++++++++--
4 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/gdb/configure b/gdb/configure
index 249a399..4c308cb 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -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. */
diff --git a/gdb/configure.ac b/gdb/configure.ac
index ebd797b..b9d8f8b 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -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"
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index ccb9639..ab03cac 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -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. */
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 5524a05..6caf91c 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -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"
--
1.9.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix -Wno-unknown-warning support detection
2015-12-16 22:58 [PATCH] Fix -Wno-unknown-warning support detection Pedro Alves
@ 2015-12-16 23:07 ` Simon Marchi
2015-12-16 23:13 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2015-12-16 23:07 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 15-12-16 05:57 PM, Pedro Alves wrote:
> 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.
> ---
> gdb/configure | 13 +++++++++++--
> gdb/configure.ac | 13 +++++++++++--
> gdb/gdbserver/configure | 13 +++++++++++--
> gdb/gdbserver/configure.ac | 13 +++++++++++--
> 4 files changed, 44 insertions(+), 8 deletions(-)
>
> diff --git a/gdb/configure b/gdb/configure
> index 249a399..4c308cb 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -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. */
>
> diff --git a/gdb/configure.ac b/gdb/configure.ac
> index ebd797b..b9d8f8b 100644
> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -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"
> diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
> index ccb9639..ab03cac 100755
> --- a/gdb/gdbserver/configure
> +++ b/gdb/gdbserver/configure
> @@ -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. */
>
> diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
> index 5524a05..6caf91c 100644
> --- a/gdb/gdbserver/configure.ac
> +++ b/gdb/gdbserver/configure.ac
> @@ -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"
>
It looks good. Note that you could have done
wtest=`echo $w | sed 's/-Wno-/-W/g'`
unconditionally. If it doesn't match, it won't replace anything:
$ echo -Wlol | sed 's/-Wno-/-W/g'
-Wlol
$ echo -Wno-lol | sed 's/-Wno-/-W/g'
-Wlol
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix -Wno-unknown-warning support detection
2015-12-16 23:07 ` Simon Marchi
@ 2015-12-16 23:13 ` Pedro Alves
0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2015-12-16 23:13 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 12/16/2015 11:07 PM, Simon Marchi wrote:
> It looks good.
I pushed it, thanks.
Note that you could have done
>
> wtest=`echo $w | sed 's/-Wno-/-W/g'`
>
> unconditionally. If it doesn't match, it won't replace anything:
>
> $ echo -Wlol | sed 's/-Wno-/-W/g'
> -Wlol
> $ echo -Wno-lol | sed 's/-Wno-/-W/g'
> -Wlol
Yep, but I wrote it like that to avoid spawning external
processes unless necessary. That adds up and slows configure down.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-16 23:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16 22:58 [PATCH] Fix -Wno-unknown-warning support detection Pedro Alves
2015-12-16 23:07 ` Simon Marchi
2015-12-16 23:13 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox