From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] [gdb/build] Rework warnings order
Date: Wed, 28 Oct 2026 11:41:10 +0100 [thread overview]
Message-ID: <20261028104110.1700720-3-tdevries@suse.de> (raw)
In-Reply-To: <20261028104110.1700720-1-tdevries@suse.de>
I looked at gdbsupport/warning.m4 and noticed that the warnings list is sorted
purely alphabetically, but not on warning name, so Wfoo, Wno-foo and
Wno-error=foo are sorted to different locations.
I tried out sorting on warning names instead, but then noticed that it's
harder to check that the warnings are in the right order.
Fix this by introducing two additional lists, build_warnings_no and
build_warnings_no_error.
Then I noticed that there are two ordering constraints:
- Wall needs to be ordered before Wno-char-subscripts and others, and
- Wno-unused needs to be ordered before Wunused-variable and others.
These constraints were met before commit df3eb64a53c ("gdbsupport:
re-format and sort warning flags"). After the commit, they still held but
only accidentally, because:
- Wall comes first alphabetically, and
- Wno-unused comes alphabetically before Wunused-variable.
Put differently, if we had applied reverse alphabetical order, both
constraints would have been broken.
Introduce another list build_warnings_base, and handle these ordering
constraints explicitly.
---
gdb/configure | 58 ++++++++++++++++++++++++++++++++++++-------
gdbserver/configure | 58 ++++++++++++++++++++++++++++++++++++-------
gdbsupport/configure | 58 ++++++++++++++++++++++++++++++++++++-------
gdbsupport/warning.m4 | 58 ++++++++++++++++++++++++++++++++++++-------
4 files changed, 196 insertions(+), 36 deletions(-)
diff --git a/gdb/configure b/gdb/configure
index 07bf6edf1d1..b30ab95a551 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -31147,9 +31147,24 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
-# The options we'll try to enable.
-build_warnings=" \
+# The options we'll try to enable. Put options we want to override using
+# build_warnings_no here. Sorted alphabetically.
+build_warnings_base=" \
-Wall \
+"
+
+# The options we'll try to disable. Sorted alphabetically.
+build_warnings_no=" \
+-Wno-char-subscripts \
+-Wno-mismatched-tags \
+-Wno-sign-compare \
+-Wno-switch \
+-Wno-unused \
+"
+
+# The options we'll try to enable. Don't put options we want to override
+# using build_warnings_no here. Sorted alphabetically.
+build_warnings=" \
-Wdangling-reference \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
@@ -31157,13 +31172,6 @@ build_warnings=" \
-Wempty-body \
-Wimplicit-fallthrough=5 \
-Wmissing-declarations \
--Wno-char-subscripts \
--Wno-error=deprecated-register \
--Wno-error=maybe-uninitialized \
--Wno-mismatched-tags \
--Wno-sign-compare \
--Wno-switch \
--Wno-unused \
-Wpointer-arith \
-Wredundant-move \
-Wshadow=local \
@@ -31184,6 +31192,14 @@ build_warnings=" \
-Wvla \
"
+# The warnings which, if enabled, we don't want to turn into errors if -Werror
+# is in effect. Note that these neither enable nor disable any warnings.
+# Sorted alphabetically.
+build_warnings_no_error=" \
+-Wno-error=deprecated-register \
+-Wno-error=maybe-uninitialized \
+"
+
# The -Wmissing-prototypes flag will be accepted by GCC, but results
# in a warning being printed about the flag not being valid for C++,
# this is something to do with using ccache, and argument ordering.
@@ -31191,6 +31207,30 @@ if test "$GDB_COMPILER_TYPE" != gcc; then
build_warnings="$build_warnings -Wmissing-prototypes"
fi
+# The order here is significant:
+# - some warnings are enabled by default
+# - build_warnings_base (contains -Wall) enables more warnings
+# - build_warnings_no switches some of those off
+# - build_warnings enables warnings that were:
+# - enabled neither by default nor by build_warnings_base,
+# for example -Wshadow=local
+# - enabled by default or build_warnings_base but disabled by
+# build_warnings_no, for example -Wno-unused and -Wunused-variable
+build_warnings=" \
+$build_warnings_base \
+$build_warnings_no \
+$build_warnings \
+"
+
+# Variable build_warnings_no_error doesn't enable or disable warnings, so the
+# concatenation order is not significant.
+build_warnings=" \
+$build_warnings \
+$build_warnings_no_error \
+"
+
+# Host-specific warning settings. Apply these last to make sure they are
+# not overridden.
case "${host}" in
*-*-mingw32*)
# Enable -Wno-format by default when using gcc on mingw since many
diff --git a/gdbserver/configure b/gdbserver/configure
index 725c28e19ad..9bcaba6550a 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -12877,9 +12877,24 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
-# The options we'll try to enable.
-build_warnings=" \
+# The options we'll try to enable. Put options we want to override using
+# build_warnings_no here. Sorted alphabetically.
+build_warnings_base=" \
-Wall \
+"
+
+# The options we'll try to disable. Sorted alphabetically.
+build_warnings_no=" \
+-Wno-char-subscripts \
+-Wno-mismatched-tags \
+-Wno-sign-compare \
+-Wno-switch \
+-Wno-unused \
+"
+
+# The options we'll try to enable. Don't put options we want to override
+# using build_warnings_no here. Sorted alphabetically.
+build_warnings=" \
-Wdangling-reference \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
@@ -12887,13 +12902,6 @@ build_warnings=" \
-Wempty-body \
-Wimplicit-fallthrough=5 \
-Wmissing-declarations \
--Wno-char-subscripts \
--Wno-error=deprecated-register \
--Wno-error=maybe-uninitialized \
--Wno-mismatched-tags \
--Wno-sign-compare \
--Wno-switch \
--Wno-unused \
-Wpointer-arith \
-Wredundant-move \
-Wshadow=local \
@@ -12914,6 +12922,14 @@ build_warnings=" \
-Wvla \
"
+# The warnings which, if enabled, we don't want to turn into errors if -Werror
+# is in effect. Note that these neither enable nor disable any warnings.
+# Sorted alphabetically.
+build_warnings_no_error=" \
+-Wno-error=deprecated-register \
+-Wno-error=maybe-uninitialized \
+"
+
# The -Wmissing-prototypes flag will be accepted by GCC, but results
# in a warning being printed about the flag not being valid for C++,
# this is something to do with using ccache, and argument ordering.
@@ -12921,6 +12937,30 @@ if test "$GDB_COMPILER_TYPE" != gcc; then
build_warnings="$build_warnings -Wmissing-prototypes"
fi
+# The order here is significant:
+# - some warnings are enabled by default
+# - build_warnings_base (contains -Wall) enables more warnings
+# - build_warnings_no switches some of those off
+# - build_warnings enables warnings that were:
+# - enabled neither by default nor by build_warnings_base,
+# for example -Wshadow=local
+# - enabled by default or build_warnings_base but disabled by
+# build_warnings_no, for example -Wno-unused and -Wunused-variable
+build_warnings=" \
+$build_warnings_base \
+$build_warnings_no \
+$build_warnings \
+"
+
+# Variable build_warnings_no_error doesn't enable or disable warnings, so the
+# concatenation order is not significant.
+build_warnings=" \
+$build_warnings \
+$build_warnings_no_error \
+"
+
+# Host-specific warning settings. Apply these last to make sure they are
+# not overridden.
case "${host}" in
*-*-mingw32*)
# Enable -Wno-format by default when using gcc on mingw since many
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 31e9732ed1a..b0a879710f2 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -13880,9 +13880,24 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
-# The options we'll try to enable.
-build_warnings=" \
+# The options we'll try to enable. Put options we want to override using
+# build_warnings_no here. Sorted alphabetically.
+build_warnings_base=" \
-Wall \
+"
+
+# The options we'll try to disable. Sorted alphabetically.
+build_warnings_no=" \
+-Wno-char-subscripts \
+-Wno-mismatched-tags \
+-Wno-sign-compare \
+-Wno-switch \
+-Wno-unused \
+"
+
+# The options we'll try to enable. Don't put options we want to override
+# using build_warnings_no here. Sorted alphabetically.
+build_warnings=" \
-Wdangling-reference \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
@@ -13890,13 +13905,6 @@ build_warnings=" \
-Wempty-body \
-Wimplicit-fallthrough=5 \
-Wmissing-declarations \
--Wno-char-subscripts \
--Wno-error=deprecated-register \
--Wno-error=maybe-uninitialized \
--Wno-mismatched-tags \
--Wno-sign-compare \
--Wno-switch \
--Wno-unused \
-Wpointer-arith \
-Wredundant-move \
-Wshadow=local \
@@ -13917,6 +13925,14 @@ build_warnings=" \
-Wvla \
"
+# The warnings which, if enabled, we don't want to turn into errors if -Werror
+# is in effect. Note that these neither enable nor disable any warnings.
+# Sorted alphabetically.
+build_warnings_no_error=" \
+-Wno-error=deprecated-register \
+-Wno-error=maybe-uninitialized \
+"
+
# The -Wmissing-prototypes flag will be accepted by GCC, but results
# in a warning being printed about the flag not being valid for C++,
# this is something to do with using ccache, and argument ordering.
@@ -13924,6 +13940,30 @@ if test "$GDB_COMPILER_TYPE" != gcc; then
build_warnings="$build_warnings -Wmissing-prototypes"
fi
+# The order here is significant:
+# - some warnings are enabled by default
+# - build_warnings_base (contains -Wall) enables more warnings
+# - build_warnings_no switches some of those off
+# - build_warnings enables warnings that were:
+# - enabled neither by default nor by build_warnings_base,
+# for example -Wshadow=local
+# - enabled by default or build_warnings_base but disabled by
+# build_warnings_no, for example -Wno-unused and -Wunused-variable
+build_warnings=" \
+$build_warnings_base \
+$build_warnings_no \
+$build_warnings \
+"
+
+# Variable build_warnings_no_error doesn't enable or disable warnings, so the
+# concatenation order is not significant.
+build_warnings=" \
+$build_warnings \
+$build_warnings_no_error \
+"
+
+# Host-specific warning settings. Apply these last to make sure they are
+# not overridden.
case "${host}" in
*-*-mingw32*)
# Enable -Wno-format by default when using gcc on mingw since many
diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
index 7cae9996765..2eb6e8dc537 100644
--- a/gdbsupport/warning.m4
+++ b/gdbsupport/warning.m4
@@ -35,9 +35,24 @@ if test "${ERROR_ON_WARNING}" = yes ; then
WERROR_CFLAGS="-Werror"
fi
-# The options we'll try to enable.
-build_warnings=" \
+# The options we'll try to enable. Put options we want to override using
+# build_warnings_no here. Sorted alphabetically.
+build_warnings_base=" \
-Wall \
+"
+
+# The options we'll try to disable. Sorted alphabetically.
+build_warnings_no=" \
+-Wno-char-subscripts \
+-Wno-mismatched-tags \
+-Wno-sign-compare \
+-Wno-switch \
+-Wno-unused \
+"
+
+# The options we'll try to enable. Don't put options we want to override
+# using build_warnings_no here. Sorted alphabetically.
+build_warnings=" \
-Wdangling-reference \
-Wdeprecated-copy \
-Wdeprecated-copy-dtor \
@@ -45,13 +60,6 @@ build_warnings=" \
-Wempty-body \
-Wimplicit-fallthrough=5 \
-Wmissing-declarations \
--Wno-char-subscripts \
--Wno-error=deprecated-register \
--Wno-error=maybe-uninitialized \
--Wno-mismatched-tags \
--Wno-sign-compare \
--Wno-switch \
--Wno-unused \
-Wpointer-arith \
-Wredundant-move \
-Wshadow=local \
@@ -72,6 +80,14 @@ build_warnings=" \
-Wvla \
"
+# The warnings which, if enabled, we don't want to turn into errors if -Werror
+# is in effect. Note that these neither enable nor disable any warnings.
+# Sorted alphabetically.
+build_warnings_no_error=" \
+-Wno-error=deprecated-register \
+-Wno-error=maybe-uninitialized \
+"
+
# The -Wmissing-prototypes flag will be accepted by GCC, but results
# in a warning being printed about the flag not being valid for C++,
# this is something to do with using ccache, and argument ordering.
@@ -79,6 +95,30 @@ if test "$GDB_COMPILER_TYPE" != gcc; then
build_warnings="$build_warnings -Wmissing-prototypes"
fi
+# The order here is significant:
+# - some warnings are enabled by default
+# - build_warnings_base (contains -Wall) enables more warnings
+# - build_warnings_no switches some of those off
+# - build_warnings enables warnings that were:
+# - enabled neither by default nor by build_warnings_base,
+# for example -Wshadow=local
+# - enabled by default or build_warnings_base but disabled by
+# build_warnings_no, for example -Wno-unused and -Wunused-variable
+build_warnings=" \
+$build_warnings_base \
+$build_warnings_no \
+$build_warnings \
+"
+
+# Variable build_warnings_no_error doesn't enable or disable warnings, so the
+# concatenation order is not significant.
+build_warnings=" \
+$build_warnings \
+$build_warnings_no_error \
+"
+
+# Host-specific warning settings. Apply these last to make sure they are
+# not overridden.
case "${host}" in
*-*-mingw32*)
# Enable -Wno-format by default when using gcc on mingw since many
--
2.51.0
prev parent reply other threads:[~2026-10-28 10:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 10:41 [PATCH 0/2] [gdb/build] Two gdbsupport/warning.m4 updates Tom de Vries
2026-10-28 10:41 ` [PATCH 1/2] [gdb/build] Put warnings one per line Tom de Vries
2026-10-28 10:41 ` Tom de Vries [this message]
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=20261028104110.1700720-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/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