From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82080 invoked by alias); 16 Dec 2015 23:07:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 82069 invoked by uid 89); 16 Dec 2015 23:07:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy= X-HELO: usplmg21.ericsson.net Received: from usplmg21.ericsson.net (HELO usplmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 16 Dec 2015 23:07:57 +0000 Received: from EUSAAHC004.ericsson.se (Unknown_Domain [147.117.188.84]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id 8A.B0.32102.4CEE1765; Thu, 17 Dec 2015 00:07:48 +0100 (CET) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.86) with Microsoft SMTP Server id 14.3.248.2; Wed, 16 Dec 2015 18:07:54 -0500 Subject: Re: [PATCH] Fix -Wno-unknown-warning support detection To: Pedro Alves , References: <1450306675-8885-1-git-send-email-palves@redhat.com> From: Simon Marchi Message-ID: <5671EECA.4080206@ericsson.com> Date: Wed, 16 Dec 2015 23:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1450306675-8885-1-git-send-email-palves@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00313.txt.bz2 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 > > * 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 > > * 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