From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4PtuI8fPTWEuOAAAWB0awg (envelope-from ) for ; Fri, 24 Sep 2021 09:16:55 -0400 Received: by simark.ca (Postfix, from userid 112) id 8EC481EE25; Fri, 24 Sep 2021 09:16:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9B4E81EDF0 for ; Fri, 24 Sep 2021 09:16:53 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3FF0B385843F for ; Fri, 24 Sep 2021 13:16:53 +0000 (GMT) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 509B1385840D for ; Fri, 24 Sep 2021 13:16:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 509B1385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42c.google.com with SMTP id i23so27517966wrb.2 for ; Fri, 24 Sep 2021 06:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=YJtu9hPQjaB9/SrVLBjdBFi382ssXxsvV/Eik58Ld/A=; b=TGLlc9RaZMz8Rv1qCg6XthTMLpmBBFbUqGmLpc+8jnmqyKhVff1ZQ/0qiTvYl8LfOG 2ohjyLz4nm1F9RqN+Sy3Kb/2VbdlpBfhLkRnLHxUKLubCCD0BNEGqls6/eRVNmBlPhTP Tq71HxJDKi5wlN9QlumrI0fuY9RpdVBkBLWHLJMNvyvJvnDRXIkwio8+4oByPlU6bvnM 22ZPbpu+nrKHRg165CCV8k0p5p0f1mcr2NQTIob0I9xGIogE7QCiXp/h2RxGcHpGnX6a qAvXwP2crgjZ8pIBmKAH46icG+SSRUtciil3UpHCU1QwX4JZgHd4x5YcD84CdmLoU9hZ o+fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=YJtu9hPQjaB9/SrVLBjdBFi382ssXxsvV/Eik58Ld/A=; b=AmwLVolYZhsJTsGTb9f1t0RjfB5Bcet8T4TdGn0UNbBMGxgJ4Cy1n/XRm/WwDLU1sV 9Ki29CQnkB1b1tZxz2nqox28Xpa5549a42bWWAd3W6LbqGbU1KeBMAVQn7vEeb3vRJDC 9tLkoL81WDUhVBGPGunYs6XZvwXenPL7NtIk0LxXBkbibTYTxeNAkWs+PzaGCDmmdEf3 JwOCeoI54HBQYL1RCEuN/PuejbT6FjNlEAF8V/V/ZeFN/T1hwdqWqZKhOfD0NIeJEHLz pmEBfDGwwkRM9FuRLKYhxLlBu1+FbRiXzy1zeAV5JOnRj6jHU65IPEaNu0o8kGjwfzxk 365w== X-Gm-Message-State: AOAM533QHqVgBTi4csKPMPCIArBqso6Jf3PJNOBQfDe9gvtR9fU0Q5NJ 6ltjkz1XY+Qv1sbZRNqRuEZ6LNVjDkPl1Q== X-Google-Smtp-Source: ABdhPJykyjdvagHpzCOQMoqCj48RF0hqWOreLNn5U+Y1KZn7nz9/7JTvaVeptTEF0Ly4uStbvCe0/Q== X-Received: by 2002:a1c:7d06:: with SMTP id y6mr2031920wmc.23.1632489393619; Fri, 24 Sep 2021 06:16:33 -0700 (PDT) Received: from localhost (host86-169-137-11.range86-169.btcentralplus.com. [86.169.137.11]) by smtp.gmail.com with ESMTPSA id s13sm12584724wmc.47.2021.09.24.06.16.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 06:16:33 -0700 (PDT) Date: Fri, 24 Sep 2021 14:16:32 +0100 From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH] gdbsupport: better detection of -Wmissing-prototypes support Message-ID: <20210924131632.GC1900093@embecosm.com> References: <20210924122933.2714720-1-andrew.burgess@embecosm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20210924122933.2714720-1-andrew.burgess@embecosm.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 14:14:10 up 5 days, 4:23, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" * Andrew Burgess [2021-09-24 13:29:33 +0100]: > When building with GCC 9.3.1 I notice lots of warnings like this while > building GDB: >=20 > cc1plus: warning: command line option =E2=80=98-Wmissing-prototypes=E2= =80=99 is valid for C/ObjC but not for C++ >=20 > This is a little strange as the configure macro, AM_GDB_WARNINGS, > should figure out which warning flags are valid, and which are not. >=20 > It turns out that there's a weird bug in some older version of GCC; > when performing only a compile, the -Wmissing-prototypes flag will > only ever produce a warning, even when -Werror is passed. If a full > compile and link is performed then an error is produced (assuming > -Werror is passed). >=20 > Of course, the AM_GDB_WARNINGS macro only tests each flag during a > compile, not a compile and link, so the macro figures that the > -Wmissing-prototypes flag is valid (even though a warning is emitted), > and adds it to the set of flags to use. >=20 > In this commit I special case the -Wmissing-prototypes check inside > AM_GDB_WARNINGS, and for that flag only, we now perform a full compile > and link. This means that the configure script can correctly detect > that the flag is not supported, and so the flag is no longer used. It has been pointed out to me on IRC (thanks Simon), that this issue is not GCC, but ccache: https://github.com/ccache/ccache/issues/738#issuecomment-740133374 So this patch certainly shouldn't go in as it is currently written. It's still pretty annoying seeing those warnings though, so I wonder if we can consider having a work around for this ccache issue in the GDB configure scripts? Maybe something as simple as setting CCACHE_DISABLE in the environment prior to running the AM_GDB_WARNINGS checks? All ideas welcome... thanks, Andrewx > --- > gdb/configure | 25 +++++++++++++++++++++++++ > gdbserver/configure | 25 +++++++++++++++++++++++++ > gdbsupport/configure | 25 +++++++++++++++++++++++++ > gdbsupport/warning.m4 | 14 ++++++++++++++ > 4 files changed, 89 insertions(+) >=20 > diff --git a/gdb/configure b/gdb/configure > index f0b1af4a6ea..1bd9a7698b7 100755 > --- a/gdb/configure > +++ b/gdb/configure > @@ -17016,6 +17016,31 @@ if ac_fn_cxx_try_compile "$LINENO"; then : > WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + elif test "x$w" =3D "x-Wmissing-prototypes"; then > + # On some versions of GCC, e.g. 9.3.1, even when -Werror > + # is passed, the -Wmissing-prototypes flag will only > + # ever produce a warning when compiling, but, will > + # produce an error when a full link is performed. This > + # bug is fixed in later versions of GCC. > + # > + # To avoid this bug, and detect if -Wmissing-prototypes > + # is supported, we do a compile and link here. > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_cxx_try_link "$LINENO"; then : > + WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > +fi > +rm -f core conftest.err conftest.$ac_objext \ > + conftest$ac_exeext conftest.$ac_ext > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > /* end confdefs.h. */ > diff --git a/gdbserver/configure b/gdbserver/configure > index b227167e270..c12354f583c 100755 > --- a/gdbserver/configure > +++ b/gdbserver/configure > @@ -9766,6 +9766,31 @@ if ac_fn_cxx_try_compile "$LINENO"; then : > WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + elif test "x$w" =3D "x-Wmissing-prototypes"; then > + # On some versions of GCC, e.g. 9.3.1, even when -Werror > + # is passed, the -Wmissing-prototypes flag will only > + # ever produce a warning when compiling, but, will > + # produce an error when a full link is performed. This > + # bug is fixed in later versions of GCC. > + # > + # To avoid this bug, and detect if -Wmissing-prototypes > + # is supported, we do a compile and link here. > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_cxx_try_link "$LINENO"; then : > + WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > +fi > +rm -f core conftest.err conftest.$ac_objext \ > + conftest$ac_exeext conftest.$ac_ext > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > /* end confdefs.h. */ > diff --git a/gdbsupport/configure b/gdbsupport/configure > index a9dd02c5b72..ff8eb517d9e 100755 > --- a/gdbsupport/configure > +++ b/gdbsupport/configure > @@ -10251,6 +10251,31 @@ if ac_fn_cxx_try_compile "$LINENO"; then : > WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > + elif test "x$w" =3D "x-Wmissing-prototypes"; then > + # On some versions of GCC, e.g. 9.3.1, even when -Werror > + # is passed, the -Wmissing-prototypes flag will only > + # ever produce a warning when compiling, but, will > + # produce an error when a full link is performed. This > + # bug is fixed in later versions of GCC. > + # > + # To avoid this bug, and detect if -Wmissing-prototypes > + # is supported, we do a compile and link here. > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > +/* end confdefs.h. */ > + > +int > +main () > +{ > + > + ; > + return 0; > +} > +_ACEOF > +if ac_fn_cxx_try_link "$LINENO"; then : > + WARN_CFLAGS=3D"${WARN_CFLAGS} $w" > +fi > +rm -f core conftest.err conftest.$ac_objext \ > + conftest$ac_exeext conftest.$ac_ext > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > /* end confdefs.h. */ > diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4 > index 46036fa461e..7bb8176b50f 100644 > --- a/gdbsupport/warning.m4 > +++ b/gdbsupport/warning.m4 > @@ -150,6 +150,20 @@ then > [WARN_CFLAGS=3D"${WARN_CFLAGS} $w"], > [] > ) > + elif test "x$w" =3D "x-Wmissing-prototypes"; then > + # On some versions of GCC, e.g. 9.3.1, even when -Werror > + # is passed, the -Wmissing-prototypes flag will only > + # ever produce a warning when compiling, but, will > + # produce an error when a full link is performed. This > + # bug is fixed in later versions of GCC. > + # > + # To avoid this bug, and detect if -Wmissing-prototypes > + # is supported, we do a compile and link here. > + AC_LINK_IFELSE( > + [AC_LANG_PROGRAM([],[])], > + [WARN_CFLAGS=3D"${WARN_CFLAGS} $w"], > + [] > + ) > else > AC_COMPILE_IFELSE( > [AC_LANG_PROGRAM([], [])], > --=20 > 2.25.4 >=20