aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-29 20:16:38 -0400
committerMike Frysinger <vapier@gentoo.org>2024-01-08 21:36:44 -0500
commit435ad222b3de93fa647fba7221eece36b1b395eb (patch)
tree596d8d68a79a4625ebb58cdde00a3080b72d8594 /sim
parent5048cb28f4a864d2426bcec8cb02f26ef3daac85 (diff)
downloadgdb-435ad222b3de93fa647fba7221eece36b1b395eb.zip
gdb-435ad222b3de93fa647fba7221eece36b1b395eb.tar.gz
gdb-435ad222b3de93fa647fba7221eece36b1b395eb.tar.bz2
sim: warnings: compile build tools with -Werror too
Add support for compiling build tools with various -Werror settings. Since the tools don't compile cleanly with the same set of flags as the rest of the sim code, we need to maintain & test a separate list. Only bother when not cross-compiling so we don't have to test all the flags against the build compiler. This should be good enough for our actual development flows.
Diffstat (limited to 'sim')
-rw-r--r--sim/Makefile.am2
-rw-r--r--sim/Makefile.in4
-rwxr-xr-xsim/configure70
-rw-r--r--sim/m4/sim_ac_option_warnings.m429
4 files changed, 100 insertions, 5 deletions
diff --git a/sim/Makefile.am b/sim/Makefile.am
index 9183b34..a6e080e 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -67,7 +67,7 @@ AM_CPPFLAGS_FOR_BUILD = \
-I$(srcroot)/include \
$(SIM_HW_CFLAGS) \
$(SIM_INLINE)
-COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(BUILD_WERROR_CFLAGS) $(BUILD_WARN_CFLAGS)
LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
## Deps to add to the install-data-local target.
diff --git a/sim/Makefile.in b/sim/Makefile.in
index c96e8a9..1e94771 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -1608,6 +1608,8 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BUILD_WARN_CFLAGS = @BUILD_WARN_CFLAGS@
+BUILD_WERROR_CFLAGS = @BUILD_WERROR_CFLAGS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
@@ -1901,7 +1903,7 @@ AM_CPPFLAGS = $(INCGNU) -I$(srcroot) -I$(srcroot)/include -I../bfd \
-,_,$(@D)_$(@F))) -I$(srcdir)/common -DSIM_TOPDIR_BUILD
AM_CPPFLAGS_FOR_BUILD = -I$(srcroot)/include $(SIM_HW_CFLAGS) \
$(SIM_INLINE) -I$(srcdir)/common
-COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(BUILD_WERROR_CFLAGS) $(BUILD_WARN_CFLAGS)
LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
SIM_INSTALL_DATA_LOCAL_DEPS =
SIM_INSTALL_EXEC_LOCAL_DEPS = $(am__append_33)
diff --git a/sim/configure b/sim/configure
index 88dc76f..e8d7be5 100755
--- a/sim/configure
+++ b/sim/configure
@@ -991,6 +991,8 @@ PACKAGE_NAME
PATH_SEPARATOR
SHELL
SIM_TOOLCHAIN_VARS
+BUILD_WERROR_CFLAGS
+BUILD_WARN_CFLAGS
WERROR_CFLAGS
WARN_CFLAGS'
ac_subst_files=''
@@ -12683,7 +12685,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12686 "configure"
+#line 12688 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12789,7 +12791,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12792 "configure"
+#line 12794 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16179,6 +16181,12 @@ build_warnings="$build_warnings
-Wstrict-prototypes
-Wno-enum-conversion
"
+build_build_warnings="
+-Wno-missing-braces
+-Wno-stringop-truncation
+-Wno-implicit-fallthrough
+-Wno-shadow=local
+"
case "${host}" in
*-*-mingw32*)
@@ -16228,9 +16236,12 @@ if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
fi
fi
WARN_CFLAGS=""
+BUILD_WARN_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
$as_echo_n "checking compiler warning flags... " >&6; }
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
@@ -16273,6 +16284,59 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
+
+ if test "x$cross_compiling" = "xno"; then :
+ SAVE_WARN_CFLAGS=$WARN_CFLAGS
+ build_warnings=$build_build_warnings
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
+$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
+ case $w in
+ -Werr*) WERROR_CFLAGS=-Werror ;;
+ *) w="$w"
+ case $w in
+ -Wno-*)
+ wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
+ -Wformat-nonliteral)
+ w="-Wformat $w"
+ wtest="$w"
+ ;;
+ *)
+ wtest=$w ;;
+ esac
+
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror $wtest"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$saved_CFLAGS"
+ ;;
+ esac
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
+$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
+
+ BUILD_WARN_CFLAGS=$WARN_CFLAGS
+ WARN_CFLAGS=$SAVE_WARN_CFLAGS
+ BUILD_WERROR_CFLAGS=$WERROR_CFLAGS
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wno-shadow=local is supported" >&5
$as_echo_n "checking whether -Wno-shadow=local is supported... " >&6; }
w="-Wno-shadow=local"
diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 7a28ca6..3b00889 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -76,6 +76,17 @@ dnl The cgen virtual insn logic involves enum conversions.
dnl Disable until we can figure out how to make this work.
-Wno-enum-conversion
"
+build_build_warnings="
+dnl TODO Fix the sh/gencode.c which triggers a ton of these warnings.
+-Wno-missing-braces
+dnl TODO Figure out the igen code that triggers warnings w/FORTIFY_SOURCE.
+-Wno-stringop-truncation
+dnl Fixing this requires ATTRIBUTE_FALLTHROUGH support at build time, but we
+dnl don't have gnulib there (yet).
+-Wno-implicit-fallthrough
+dnl TODO Enable this after cleaning up code.
+-Wno-shadow=local
+"
case "${host}" in
*-*-mingw32*)
@@ -123,8 +134,10 @@ if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
fi])dnl
WARN_CFLAGS=""
+BUILD_WARN_CFLAGS=""
if test "x${build_warnings}" != x -a "x$GCC" = xyes
then
+AC_DEFUN([_SIM_TEST_ALL_WARNING_FLAGS], [dnl
AC_MSG_CHECKING(compiler warning flags)
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
@@ -135,6 +148,20 @@ then
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
+])
+
+ dnl Test the host flags.
+ _SIM_TEST_ALL_WARNING_FLAGS
+
+ dnl Test the build flags.
+ AS_IF([test "x$cross_compiling" = "xno"], [dnl
+ SAVE_WARN_CFLAGS=$WARN_CFLAGS
+ build_warnings=$build_build_warnings
+ _SIM_TEST_ALL_WARNING_FLAGS
+ BUILD_WARN_CFLAGS=$WARN_CFLAGS
+ WARN_CFLAGS=$SAVE_WARN_CFLAGS
+ BUILD_WERROR_CFLAGS=$WERROR_CFLAGS
+ ])
dnl Test individual flags to export to dedicated variables.
m4_map([_SIM_EXPORT_WARNING_FLAG], m4_split(m4_normalize([
@@ -183,3 +210,5 @@ AC_DEFUN([_SIM_EXPORT_WARNING_FLAG], [dnl
])
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)
+AC_SUBST(BUILD_WARN_CFLAGS)
+AC_SUBST(BUILD_WERROR_CFLAGS)