From patchwork Wed Dec 16 22:57:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 10043 Received: (qmail 69849 invoked by alias); 16 Dec 2015 22:58:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 69835 invoked by uid 89); 16 Dec 2015 22:57:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_20, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=$as_echo_n, as_echo_n, confdefsh, _aceof X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Dec 2015 22:57:58 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 41D2DA99A for ; Wed, 16 Dec 2015 22:57:57 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBGMvuhm024881 for ; Wed, 16 Dec 2015 17:57:56 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Fix -Wno-unknown-warning support detection Date: Wed, 16 Dec 2015 22:57:55 +0000 Message-Id: <1450306675-8885-1-git-send-email-palves@redhat.com> 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"