From: Simon Marchi <simark@simark.ca>
To: Simon Marchi <simon.marchi@efficios.com>,
gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>,
Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH v2 0/7] Enable -Wmissing-declarations diagnostic
Date: Sun, 12 Jan 2020 20:23:00 -0000 [thread overview]
Message-ID: <b5ce4f4b-e916-cc68-c344-2a00fae0bb80@simark.ca> (raw)
In-Reply-To: <20200110220027.26450-1-simon.marchi@efficios.com>
On 2020-01-10 5:00 p.m., Simon Marchi wrote:
> This is v2 of:
>
> https://sourceware.org/ml/gdb-patches/2019-11/msg00805.html
>
> Although a few patches of the original series were merged, since they
> were valid fixes in any case.
>
> I have re-generated the configure script for gdbserver, which I had
> forgotten in v1, and it of course unearthed some more issues.
>
> I have build-tested the series with gcc 7.4.0 and clang 9.
As I tried building gdbserver with a few cross compilers, I found another
build issue, with code generated by regdat.sh. The following patch addresses
it. It should not be too controversial, but I wanted to run it by you first.
From ff6633d14065273791b5b70266f4afceba22aeec Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Sun, 12 Jan 2020 13:09:46 -0500
Subject: [PATCH] gdb: make regformats output a declaration for the init
function
When compiling gdbserver for an architecture that uses the regdat.sh
script (such as m68k) and the -Wmissing-declarations compiler flag, I
get:
REGDAT reg-m68k-generated.c
CXX reg-m68k.o
reg-m68k-generated.c:30:1: error: no previous declaration for 'void init_registers_m68k()' [-Werror=missing-declarations]
30 | init_registers_m68k (void)
| ^~~~~~~~~~~~~~~~~~~
The same happens with other architectures, such as s390, but I'll be
using 68k as an example.
The init_registers_m68k function is defined in reg-m68k-generated.c,
which is produced by the regformats/regdat.sh script. This script reads
the regformats/reg-m68k.dat file, containing a register description, and
produces C code that creates a corresponding target description at
runtime.
The init_registers_m68k function is invoked at initialization time in
linux-m68k-low.c. The function must therefore be non-static, but does
not have a declaration at the moment.
The real clean way of fixing this would be to make regdat.sh generate a
.h file (in addition to the .c file) with declarations for whatever is
in the .c file. The generated .c file would include the .h file, and
therefore the definition would have a corresponding declaration. The
linux-m68k-low.c file would also include this .h file, instead of having
its own declaration of init_registers_m68k, like it does now.
However, this would be a quite big change for not much gain. As far as
I understand, some common architectures (i386, x86-64, ARM, AArch64)
have been moved to dynamically building target descriptions based on
features (the linux-*-tdesc.c files in gdbserver) and don't use
regdat.sh anymore. Logically (and given infinite development
resources), the other architectures would be migrated to this system too
and the regdat.sh script would be dropped. A new architecture would
probably not use regdat.sh either. So I therefore propose this simpler
patch instead, which just adds a local declaration in the generated
file.
gdb/ChangeLog:
* regformats/regdat.sh: Generate declaration for init function.
---
gdb/regformats/regdat.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 1839a881213c..a40f2336484f 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -127,6 +127,10 @@ do
echo "const struct target_desc *tdesc_${name};"
echo ""
+
+ # This is necessary for -Wmissing-declarations.
+ echo "void init_registers_${name} (void);"
+
echo "void"
echo "init_registers_${name} (void)"
echo "{"
--
2.24.1
next prev parent reply other threads:[~2020-01-12 20:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-10 22:00 Simon Marchi
2020-01-10 22:00 ` [PATCH v2 2/7] gdb: add declaration to Python init function Simon Marchi
2020-01-10 22:00 ` [PATCH v2 4/7] gdbserver: include gdbsupport/common-inferior.h in inferiors.c Simon Marchi
2020-01-10 22:00 ` [PATCH v2 3/7] gdbserver: include hostio.h in hostio-errno.c Simon Marchi
2020-01-10 22:00 ` [PATCH v2 7/7] Enable -Wmissing-declarations diagnostic Simon Marchi
2020-01-11 3:33 ` Simon Marchi
2020-01-10 22:01 ` [PATCH v2 1/7] gdb: add back declarations for _initialize functions Simon Marchi
2020-01-11 3:32 ` Simon Marchi
2020-01-10 22:09 ` [PATCH v2 5/7] gdbserver: make some functions static in linux-x86-low.c Simon Marchi
2020-01-10 22:09 ` [PATCH v2 6/7] gdbserver: set IP_AGENT_EXPORT_FUNC to static when not building IPA, add declarations Simon Marchi
2020-01-11 18:11 ` [PATCH v2 0/7] Enable -Wmissing-declarations diagnostic Tom Tromey
2020-01-11 17:29 ` Tom Tromey
2020-01-12 7:06 ` Simon Marchi
2020-01-13 19:19 ` Simon Marchi
2020-01-12 8:13 ` Joel Brobecker
2020-01-12 20:23 ` Simon Marchi [this message]
2020-01-13 17:42 ` Tom Tromey
2020-01-13 19:10 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5ce4f4b-e916-cc68-c344-2a00fae0bb80@simark.ca \
--to=simark@simark.ca \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox