From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH/committed] sim: warnings: sync some build logic from gdbsupport
Date: Tue, 5 Dec 2023 23:12:56 -0700 [thread overview]
Message-ID: <20231206061256.6528-1-vapier@gentoo.org> (raw)
This fixes testing of -Wno flags, and adds some more portable ones.
---
sim/configure | 39 ++++++++++++++++++++++++------
sim/m4/sim_ac_option_warnings.m4 | 41 +++++++++++++++++++++++++-------
2 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/sim/configure b/sim/configure
index 32cd8fb051fc..73a638f0798e 100755
--- a/sim/configure
+++ b/sim/configure
@@ -15802,7 +15802,6 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sim_trace" >&5
$as_echo "$sim_trace" >&6; }
-
# Check whether --enable-werror was given.
if test "${enable_werror+set}" = set; then :
enableval=$enable_werror; case "${enableval}" in
@@ -15834,11 +15833,21 @@ build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith
-Wold-style-declaration -Wold-style-definition
"
-# Enable -Wno-format by default when using gcc on mingw since many
-# GCC versions complain about %I64.
case "${host}" in
- *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
- *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+ *-*-mingw32*)
+ # Enable -Wno-format by default when using gcc on mingw since many
+ # GCC versions complain about %I64.
+ build_warnings="$build_warnings -Wno-format" ;;
+ *-*-solaris*)
+ # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
+ # doesn't understand.
+ build_warnings="$build_warnings -Wno-unknown-pragmas"
+ # Solaris 11 <unistd.h> marks vfork deprecated.
+ build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
+ *)
+ # Note that gcc requires -Wformat for -Wformat-nonliteral to work,
+ # but there's a special case for this below.
+ build_warnings="$build_warnings -Wformat-nonliteral" ;;
esac
# Check whether --enable-build-warnings was given.
@@ -15879,11 +15888,27 @@ $as_echo_n "checking compiler warning flags... " >&6; }
# 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 that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror $w"
+ CFLAGS="$CFLAGS -Werror $wtest"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 16d358b0bbaa..b66e0ec3b5c3 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -15,8 +15,7 @@ dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl
dnl --enable-build-warnings is for developers of the simulator.
dnl it enables extra GCC specific warnings.
-AC_DEFUN([SIM_AC_OPTION_WARNINGS],
-[
+AC_DEFUN([SIM_AC_OPTION_WARNINGS], [dnl
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
[case "${enableval}" in
@@ -49,11 +48,21 @@ build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith
-Wold-style-declaration -Wold-style-definition
"
-# Enable -Wno-format by default when using gcc on mingw since many
-# GCC versions complain about %I64.
case "${host}" in
- *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
- *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+ *-*-mingw32*)
+ # Enable -Wno-format by default when using gcc on mingw since many
+ # GCC versions complain about %I64.
+ build_warnings="$build_warnings -Wno-format" ;;
+ *-*-solaris*)
+ # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
+ # doesn't understand.
+ build_warnings="$build_warnings -Wno-unknown-pragmas"
+ # Solaris 11 <unistd.h> marks vfork deprecated.
+ build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
+ *)
+ # Note that gcc requires -Wformat for -Wformat-nonliteral to work,
+ # but there's a special case for this below.
+ build_warnings="$build_warnings -Wformat-nonliteral" ;;
esac
AC_ARG_ENABLE(build-warnings,
@@ -91,11 +100,27 @@ 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 that GCC accepts it
+ *)
+ # Check whether GCC accepts it.
saved_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror $w"
+ CFLAGS="$CFLAGS -Werror $wtest"
AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
CFLAGS="$saved_CFLAGS"
esac
--
2.43.0
reply other threads:[~2023-12-06 6:12 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=20231206061256.6528-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).