public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: enable -Wmissing-prototypes warning
@ 2020-03-03 22:34 Simon Marchi
  2020-03-11 19:16 ` Simon Marchi
  2021-11-04 12:00 ` gdb: disable -Wmissing-prototypes warning w/gcc Mike Frysinger
  0 siblings, 2 replies; 7+ messages in thread
From: Simon Marchi @ 2020-03-03 22:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

While compiling with clang, I noticed it didn't catch cases where my
function declaration didn't match my function definition.  This is
normally caught by gcc with -Wmissing-declarations.

On clang, this is caught by -Wmissing-prototypes instead.

Note that on gcc, -Wmissing-prototypes also exists, but is only valid
for C and Objective-C.  It gets correctly rejected by the configure
script since gcc rejects it with:

    cc1plus: error: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ -Werror

So this warning flag ends up not used for gcc (which is what we want).

gdb/ChangeLog:

	* configure: Re-generate.

gdbserver/ChangeLog:

	* configure: Re-generate.

gdbsupport/ChangeLog:

	* configure: Re-generate.
	* warning.m4: Enable -Wmissing-prototypes.
---
 gdb/configure         | 1 +
 gdbserver/configure   | 1 +
 gdbsupport/configure  | 1 +
 gdbsupport/warning.m4 | 1 +
 4 files changed, 4 insertions(+)

diff --git a/gdb/configure b/gdb/configure
index f99cbe40f11f..47ca77f400c8 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -16323,6 +16323,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wdeprecated-copy-dtor \
 -Wredundant-move \
 -Wmissing-declarations \
+-Wmissing-prototypes \
 -Wstrict-null-sentinel \
 "
 
diff --git a/gdbserver/configure b/gdbserver/configure
index be5719eb77aa..13ac7188454d 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -9616,6 +9616,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wdeprecated-copy-dtor \
 -Wredundant-move \
 -Wmissing-declarations \
+-Wmissing-prototypes \
 -Wstrict-null-sentinel \
 "
 
diff --git a/gdbsupport/configure b/gdbsupport/configure
index a4871f8d5bce..11ebee513c40 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10871,6 +10871,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wdeprecated-copy-dtor \
 -Wredundant-move \
 -Wmissing-declarations \
+-Wmissing-prototypes \
 -Wstrict-null-sentinel \
 "
 
diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
index 81939ed76102..649be7552dd1 100644
--- a/gdbsupport/warning.m4
+++ b/gdbsupport/warning.m4
@@ -51,6 +51,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wdeprecated-copy-dtor \
 -Wredundant-move \
 -Wmissing-declarations \
+-Wmissing-prototypes \
 -Wstrict-null-sentinel \
 "
 
-- 
2.25.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gdb: enable -Wmissing-prototypes warning
  2020-03-03 22:34 [PATCH] gdb: enable -Wmissing-prototypes warning Simon Marchi
@ 2020-03-11 19:16 ` Simon Marchi
  2021-11-04 12:00 ` gdb: disable -Wmissing-prototypes warning w/gcc Mike Frysinger
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2020-03-11 19:16 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 2020-03-03 5:34 p.m., Simon Marchi wrote:
> While compiling with clang, I noticed it didn't catch cases where my
> function declaration didn't match my function definition.  This is
> normally caught by gcc with -Wmissing-declarations.
> 
> On clang, this is caught by -Wmissing-prototypes instead.
> 
> Note that on gcc, -Wmissing-prototypes also exists, but is only valid
> for C and Objective-C.  It gets correctly rejected by the configure
> script since gcc rejects it with:
> 
>     cc1plus: error: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ -Werror
> 
> So this warning flag ends up not used for gcc (which is what we want).
> 
> gdb/ChangeLog:
> 
> 	* configure: Re-generate.
> 
> gdbserver/ChangeLog:
> 
> 	* configure: Re-generate.
> 
> gdbsupport/ChangeLog:
> 
> 	* configure: Re-generate.
> 	* warning.m4: Enable -Wmissing-prototypes.

I just pushed this patch.

Simon




^ permalink raw reply	[flat|nested] 7+ messages in thread

* gdb: disable -Wmissing-prototypes warning w/gcc
  2020-03-03 22:34 [PATCH] gdb: enable -Wmissing-prototypes warning Simon Marchi
  2020-03-11 19:16 ` Simon Marchi
@ 2021-11-04 12:00 ` Mike Frysinger
  2021-11-04 12:17   ` Andrew Burgess
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2021-11-04 12:00 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]

On 03 Mar 2020 17:34, Simon Marchi wrote:
> While compiling with clang, I noticed it didn't catch cases where my
> function declaration didn't match my function definition.  This is
> normally caught by gcc with -Wmissing-declarations.
> 
> On clang, this is caught by -Wmissing-prototypes instead.
> 
> Note that on gcc, -Wmissing-prototypes also exists, but is only valid
> for C and Objective-C.  It gets correctly rejected by the configure
> script since gcc rejects it with:
> 
>     cc1plus: error: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ -Werror
> 
> So this warning flag ends up not used for gcc (which is what we want).

so ccache has a long standing bug where it mishandles -Werror with other
-W options causing the configure test to pass when it shouldn't.
https://github.com/ccache/ccache/issues/738

that means ccache+gcc builds of gdb are full of annoying logs:
  CXX    cli/cli-decode.o
cc1plus: warning: command-line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++

i get that the configure script here isn't wrong, but there aren't any
knobs in here that i can tweak to workaround the issue either, and i'm
trying to avoid carrying patches in all my local branches, and configure
files are kind of meant to deal with all sorts of system warts.

so random terrible idea below.
-mike

--- a/gdbsupport/warning.m4
+++ b/gdbsupport/warning.m4
@@ -51,10 +51,15 @@ build_warnings="-Wall -Wpointer-arith \
 -Wdeprecated-copy-dtor \
 -Wredundant-move \
 -Wmissing-declarations \
--Wmissing-prototypes \
 -Wstrict-null-sentinel \
 "
 
+# GCC doesn't support this flag currently, and probing via ccache breaks.
+# https://github.com/ccache/ccache/issues/738
+if test "${GCC}" != yes ; then
+  build_warnings="$build_warnings -Wmissing-prototypes"
+fi
+
 case "${host}" in
   *-*-mingw32*)
     # Enable -Wno-format by default when using gcc on mingw since many

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gdb: disable -Wmissing-prototypes warning w/gcc
  2021-11-04 12:00 ` gdb: disable -Wmissing-prototypes warning w/gcc Mike Frysinger
@ 2021-11-04 12:17   ` Andrew Burgess
  2021-11-04 12:59     ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-11-04 12:17 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

* Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-11-04 08:00:53 -0400]:

> On 03 Mar 2020 17:34, Simon Marchi wrote:
> > While compiling with clang, I noticed it didn't catch cases where my
> > function declaration didn't match my function definition.  This is
> > normally caught by gcc with -Wmissing-declarations.
> > 
> > On clang, this is caught by -Wmissing-prototypes instead.
> > 
> > Note that on gcc, -Wmissing-prototypes also exists, but is only valid
> > for C and Objective-C.  It gets correctly rejected by the configure
> > script since gcc rejects it with:
> > 
> >     cc1plus: error: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ -Werror
> > 
> > So this warning flag ends up not used for gcc (which is what we want).
> 
> so ccache has a long standing bug where it mishandles -Werror with other
> -W options causing the configure test to pass when it shouldn't.
> https://github.com/ccache/ccache/issues/738
> 
> that means ccache+gcc builds of gdb are full of annoying logs:
>   CXX    cli/cli-decode.o
> cc1plus: warning: command-line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
> 
> i get that the configure script here isn't wrong, but there aren't any
> knobs in here that i can tweak to workaround the issue either, and i'm
> trying to avoid carrying patches in all my local branches, and configure
> files are kind of meant to deal with all sorts of system warts.
> 
> so random terrible idea below.
> -mike
> 
> --- a/gdbsupport/warning.m4
> +++ b/gdbsupport/warning.m4
> @@ -51,10 +51,15 @@ build_warnings="-Wall -Wpointer-arith \
>  -Wdeprecated-copy-dtor \
>  -Wredundant-move \
>  -Wmissing-declarations \
> --Wmissing-prototypes \
>  -Wstrict-null-sentinel \
>  "
>  
> +# GCC doesn't support this flag currently, and probing via ccache breaks.
> +# https://github.com/ccache/ccache/issues/738
> +if test "${GCC}" != yes ; then
> +  build_warnings="$build_warnings -Wmissing-prototypes"
> +fi
> +
>  case "${host}" in
>    *-*-mingw32*)
>      # Enable -Wno-format by default when using gcc on mingw since many

I also tried to solve this issue, but went in a different direction:

  https://sourceware.org/pipermail/gdb-patches/2021-September/182148.html

However, Pedro objected.  He would prefer to see a solution exactly
like you proposed above.  The only reason I didn't immediately knock
out a patch was that I didn't know how to check if GCC was the
compiler or not.  Turns out it's pretty easy :)

So, what you wrote gets my +1, and based on the feedback on my thread,
I don't think anyone else will object.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gdb: disable -Wmissing-prototypes warning w/gcc
  2021-11-04 12:17   ` Andrew Burgess
@ 2021-11-04 12:59     ` Simon Marchi
  2021-11-04 18:43       ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2021-11-04 12:59 UTC (permalink / raw)
  To: Andrew Burgess, Simon Marchi, gdb-patches



On 2021-11-04 08:17, Andrew Burgess via Gdb-patches wrote:
> * Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> [2021-11-04 08:00:53 -0400]:
> 
>> On 03 Mar 2020 17:34, Simon Marchi wrote:
>>> While compiling with clang, I noticed it didn't catch cases where my
>>> function declaration didn't match my function definition.  This is
>>> normally caught by gcc with -Wmissing-declarations.
>>>
>>> On clang, this is caught by -Wmissing-prototypes instead.
>>>
>>> Note that on gcc, -Wmissing-prototypes also exists, but is only valid
>>> for C and Objective-C.  It gets correctly rejected by the configure
>>> script since gcc rejects it with:
>>>
>>>     cc1plus: error: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++ -Werror
>>>
>>> So this warning flag ends up not used for gcc (which is what we want).
>>
>> so ccache has a long standing bug where it mishandles -Werror with other
>> -W options causing the configure test to pass when it shouldn't.
>> https://github.com/ccache/ccache/issues/738
>>
>> that means ccache+gcc builds of gdb are full of annoying logs:
>>   CXX    cli/cli-decode.o
>> cc1plus: warning: command-line option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
>>
>> i get that the configure script here isn't wrong, but there aren't any
>> knobs in here that i can tweak to workaround the issue either, and i'm
>> trying to avoid carrying patches in all my local branches, and configure
>> files are kind of meant to deal with all sorts of system warts.
>>
>> so random terrible idea below.
>> -mike
>>
>> --- a/gdbsupport/warning.m4
>> +++ b/gdbsupport/warning.m4
>> @@ -51,10 +51,15 @@ build_warnings="-Wall -Wpointer-arith \
>>  -Wdeprecated-copy-dtor \
>>  -Wredundant-move \
>>  -Wmissing-declarations \
>> --Wmissing-prototypes \
>>  -Wstrict-null-sentinel \
>>  "
>>  
>> +# GCC doesn't support this flag currently, and probing via ccache breaks.
>> +# https://github.com/ccache/ccache/issues/738
>> +if test "${GCC}" != yes ; then
>> +  build_warnings="$build_warnings -Wmissing-prototypes"
>> +fi

Just wondering, does anybody care about building GDB with a compiler
other than GCC and Clang?  Because another way that excludes the warning
just for gcc (rather than include it for anything that isn't gcc) would
be (in pseudo code):

diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
index 46036fa461e8..33a729a60d5d 100644
--- a/gdbsupport/warning.m4
+++ b/gdbsupport/warning.m4
@@ -150,7 +150,7 @@ then
 		[WARN_CFLAGS="${WARN_CFLAGS} $w"],
 		[]
 	      )
-	    else
+	    elif (compiler is not gcc) or (warning is not -Wmissing-prototypes); then
 	      AC_COMPILE_IFELSE(
 		[AC_LANG_PROGRAM([], [])],
 		[WARN_CFLAGS="${WARN_CFLAGS} $w"],

If that works, I think it would be preferable, but otherwise I think
your patch is OK.  Please push whatever makes the most sense to you, so
we can finally get rid of this warning :).

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gdb: disable -Wmissing-prototypes warning w/gcc
  2021-11-04 12:59     ` Simon Marchi
@ 2021-11-04 18:43       ` Simon Marchi
  2021-11-04 20:18         ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2021-11-04 18:43 UTC (permalink / raw)
  To: Andrew Burgess, Simon Marchi, gdb-patches

> Just wondering, does anybody care about building GDB with a compiler
> other than GCC and Clang?  Because another way that excludes the warning
> just for gcc (rather than include it for anything that isn't gcc) would
> be (in pseudo code):
> 
> diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
> index 46036fa461e8..33a729a60d5d 100644
> --- a/gdbsupport/warning.m4
> +++ b/gdbsupport/warning.m4
> @@ -150,7 +150,7 @@ then
>  		[WARN_CFLAGS="${WARN_CFLAGS} $w"],
>  		[]
>  	      )
> -	    else
> +	    elif (compiler is not gcc) or (warning is not -Wmissing-prototypes); then
>  	      AC_COMPILE_IFELSE(
>  		[AC_LANG_PROGRAM([], [])],
>  		[WARN_CFLAGS="${WARN_CFLAGS} $w"],
> 
> If that works, I think it would be preferable, but otherwise I think
> your patch is OK.  Please push whatever makes the most sense to you, so
> we can finally get rid of this warning :).
> 
> Simon
> 

Hmm, actually using $GCC doesn't work: it gets set to yes even when
building with clang.  I think it means more "does the compiler supports
the GNU extension", which the clang compiler supports, for the most
part.  And the goal is to have -Wmissing-prototypes when building with
clang.

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gdb: disable -Wmissing-prototypes warning w/gcc
  2021-11-04 18:43       ` Simon Marchi
@ 2021-11-04 20:18         ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-04 20:18 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Andrew Burgess, Simon Marchi, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1458 bytes --]

On 04 Nov 2021 14:43, Simon Marchi via Gdb-patches wrote:
> > Just wondering, does anybody care about building GDB with a compiler
> > other than GCC and Clang?  Because another way that excludes the warning
> > just for gcc (rather than include it for anything that isn't gcc) would
> > be (in pseudo code):
> > 
> > diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
> > index 46036fa461e8..33a729a60d5d 100644
> > --- a/gdbsupport/warning.m4
> > +++ b/gdbsupport/warning.m4
> > @@ -150,7 +150,7 @@ then
> >  		[WARN_CFLAGS="${WARN_CFLAGS} $w"],
> >  		[]
> >  	      )
> > -	    else
> > +	    elif (compiler is not gcc) or (warning is not -Wmissing-prototypes); then
> >  	      AC_COMPILE_IFELSE(
> >  		[AC_LANG_PROGRAM([], [])],
> >  		[WARN_CFLAGS="${WARN_CFLAGS} $w"],
> > 
> > If that works, I think it would be preferable, but otherwise I think
> > your patch is OK.  Please push whatever makes the most sense to you, so
> > we can finally get rid of this warning :).
> 
> Hmm, actually using $GCC doesn't work: it gets set to yes even when
> building with clang.  I think it means more "does the compiler supports
> the GNU extension", which the clang compiler supports, for the most
> part.  And the goal is to have -Wmissing-prototypes when building with
> clang.

we could invert the logic: only add the flag if it's clang.

we can test for clang via --version grep or a __clang__ preproc test.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-04 20:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 22:34 [PATCH] gdb: enable -Wmissing-prototypes warning Simon Marchi
2020-03-11 19:16 ` Simon Marchi
2021-11-04 12:00 ` gdb: disable -Wmissing-prototypes warning w/gcc Mike Frysinger
2021-11-04 12:17   ` Andrew Burgess
2021-11-04 12:59     ` Simon Marchi
2021-11-04 18:43       ` Simon Marchi
2021-11-04 20:18         ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).