From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH/committed] sim: warnings: rework individual flag disable into dedicated vars
Date: Sat, 23 Dec 2023 01:22:48 -0500 [thread overview]
Message-ID: <20231223062248.20111-1-vapier@gentoo.org> (raw)
The -Wshadow=local is too new for some compilers, so move it to a var
that we test at configure time.
---
sim/Makefile.in | 9 ++-
sim/configure | 127 +++++++++++++++++++++++++------
sim/cris/local.mk | 6 +-
sim/m4/sim_ac_option_warnings.m4 | 66 +++++++++++-----
4 files changed, 157 insertions(+), 51 deletions(-)
diff --git a/sim/cris/local.mk b/sim/cris/local.mk
index a8eea65572ad..fe3f3c8d043c 100644
--- a/sim/cris/local.mk
+++ b/sim/cris/local.mk
@@ -17,10 +17,10 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## Some CGEN kludges are causing build-time warnings. See cris.cpu for details.
-AM_CFLAGS_%C%_mloopv10f.o = -Wno-unused-but-set-variable
-AM_CFLAGS_%C%_mloopv32f.o = -Wno-unused-but-set-variable
+AM_CFLAGS_%C%_mloopv10f.o = $(SIM_CFLAG_WNO_UNUSED_BUT_SET_VARIABLE)
+AM_CFLAGS_%C%_mloopv32f.o = $(SIM_CFLAG_WNO_UNUSED_BUT_SET_VARIABLE)
## Some CGEN assignments use variable names that are nested & repeated.
-AM_CFLAGS_%C%_mloopv10f.o += -Wno-shadow=local
+AM_CFLAGS_%C%_mloopv10f.o += $(SIM_CFLAG_WNO_SHADOW_LOCAL)
nodist_%C%_libsim_a_SOURCES = \
%D%/modules.c
diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 1c2d09152306..02b5ffaa5c76 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -128,33 +128,57 @@ 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'` ;;
- -Wformat-nonliteral)
- # gcc requires -Wformat before -Wformat-nonliteral
- # will work, so stick them together.
- w="-Wformat $w"
- wtest="$w"
- ;;
- *)
- wtest=$w ;;
- esac
-
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *)
- # Check whether GCC accepts it.
- saved_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror $wtest"
- AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
- CFLAGS="$saved_CFLAGS"
+ *) _SIM_TEST_WARNING_FLAG($w, [WARN_CFLAGS="${WARN_CFLAGS} $w"]) ;;
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
+
+ dnl Test individual flags to export to dedicated variables.
+ m4_map([_SIM_EXPORT_WARNING_FLAG], m4_split(m4_normalize([
+ -Wno-shadow=local
+ -Wno-unused-but-set-variable
+ ])))dnl
fi
])
+dnl Test a warning flag $1 and execute $2 if it passes, else $3.
+AC_DEFUN([_SIM_TEST_WARNING_FLAG], [dnl
+ dnl GCC does not complain about -Wno-unknown-warning. Invert
+ dnl and test -Wunknown-warning instead.
+ w="$1"
+ case $w in
+ -Wno-*)
+ wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
+ -Wformat-nonliteral)
+ dnl gcc requires -Wformat before -Wformat-nonliteral
+ dnl will work, so stick them together.
+ w="-Wformat $w"
+ wtest="$w"
+ ;;
+ *)
+ wtest=$w ;;
+ esac
+
+ dnl Check whether GCC accepts it.
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror $wtest"
+ AC_TRY_COMPILE([],[],$2,$3)
+ CFLAGS="$saved_CFLAGS"
+])
+dnl Export variable $1 to $2 for use in makefiles.
+AC_DEFUN([_SIM_EXPORT_WARNING], [dnl
+ AS_VAR_SET($1, $2)
+ AC_SUBST($1)
+])
+dnl Test if $1 is a known warning flag, and export a variable for makefiles.
+dnl If $1=-Wfoo, then SIM_CFLAG_WFOO will be set to -Wfoo if it's supported.
+AC_DEFUN([_SIM_EXPORT_WARNING_FLAG], [dnl
+ AC_MSG_CHECKING([whether $1 is supported])
+ _SIM_TEST_WARNING_FLAG($1, [dnl
+ _SIM_EXPORT_WARNING([SIM_CFLAG]m4_toupper(m4_translit($1, [-= ], [__])), $1)
+ AC_MSG_RESULT(yes)
+ ], [AC_MSG_RESULT(no)])
+])
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)
--
2.43.0
reply other threads:[~2023-12-23 6:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20231223062248.20111-1-vapier@gentoo.org \
--to=vapier@gentoo.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).