[2/2] sim: unify werror build settings

Message ID 20210618052128.5014-2-vapier@gentoo.org
State New
Headers show
Series
  • [1/2] sim: create a makefile fragment to pass common settings
Related show

Commit Message

Philippe Waroquiers via Gdb-patches June 18, 2021, 5:21 a.m.
Move these options up to the common dir so we only test & export
them once across all ports.  It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
---
 sim/Makefile.am                |   1 +
 sim/Makefile.in                |   4 ++
 sim/aarch64/aclocal.m4         |   1 -
 sim/aarch64/configure          | 114 +--------------------------------
 sim/aclocal.m4                 |   1 +
 sim/arch-subdir.mk.in          |   3 +
 sim/arm/aclocal.m4             |   1 -
 sim/arm/configure              | 114 +--------------------------------
 sim/avr/aclocal.m4             |   1 -
 sim/avr/configure              | 114 +--------------------------------
 sim/bfin/aclocal.m4            |   1 -
 sim/bfin/configure             | 114 +--------------------------------
 sim/common/Make-common.in      |   2 -
 sim/configure                  | 112 +++++++++++++++++++++++++++++++-
 sim/configure.ac               |   1 +
 sim/cr16/aclocal.m4            |   1 -
 sim/cr16/configure             | 114 +--------------------------------
 sim/d10v/aclocal.m4            |   1 -
 sim/d10v/configure             | 114 +--------------------------------
 sim/example-synacor/aclocal.m4 |   1 -
 sim/example-synacor/configure  | 114 +--------------------------------
 sim/ft32/aclocal.m4            |   1 -
 sim/ft32/configure             | 114 +--------------------------------
 sim/h8300/aclocal.m4           |   1 -
 sim/h8300/configure            | 114 +--------------------------------
 sim/m32c/aclocal.m4            |   1 -
 sim/m32c/configure             | 114 +--------------------------------
 sim/m4/sim_ac_output.m4        |   1 -
 sim/m68hc11/aclocal.m4         |   1 -
 sim/m68hc11/configure          | 114 +--------------------------------
 sim/mcore/aclocal.m4           |   1 -
 sim/mcore/configure            | 114 +--------------------------------
 sim/microblaze/aclocal.m4      |   1 -
 sim/microblaze/configure       | 114 +--------------------------------
 sim/mn10300/aclocal.m4         |   1 -
 sim/mn10300/configure          | 114 +--------------------------------
 sim/moxie/aclocal.m4           |   1 -
 sim/moxie/configure            | 114 +--------------------------------
 sim/msp430/aclocal.m4          |   1 -
 sim/msp430/configure           | 114 +--------------------------------
 sim/pru/aclocal.m4             |   1 -
 sim/pru/configure              | 114 +--------------------------------
 sim/riscv/aclocal.m4           |   1 -
 sim/riscv/configure            | 114 +--------------------------------
 sim/rl78/aclocal.m4            |   1 -
 sim/rl78/configure             | 114 +--------------------------------
 sim/rx/aclocal.m4              |   1 -
 sim/rx/configure               | 114 +--------------------------------
 sim/v850/aclocal.m4            |   1 -
 sim/v850/configure             | 114 +--------------------------------
 50 files changed, 163 insertions(+), 2377 deletions(-)

-- 
2.31.1

Comments

Philippe Waroquiers via Gdb-patches June 19, 2021, 2:39 p.m. | #1
On 2021-06-18 1:21 a.m., Mike Frysinger via Gdb-patches wrote:
> Move these options up to the common dir so we only test & export

> them once across all ports.  It also enables -Werror usage on the

> common files we've been pulling out of arch subdirs.


I get:


  CC       common/common_libcommon_a-sim-load.o
In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                 from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                 from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                 from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                 from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]
   39 | #define offset_N XCONCAT2(offset_,N)
      |                           ^~~~~~~
/home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’
   23 | #define CONCAT2(a,b)     a##b
      |                          ^
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’
   39 | #define offset_N XCONCAT2(offset_,N)
      |                  ^~~~~~~~
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’
  138 | offset_N (unsigned_N *x,
      | ^~~~~~~~

This works:


diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h
index 2750fa93cbc7..cad36e796cbc 100644
--- a/sim/common/sim-inline.h
+++ b/sim/common/sim-inline.h
@@ -445,7 +445,7 @@
      && !defined (SIM_ENDIAN_C) \
      && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
 # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
-#  define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED
+#  define INLINE_SIM_ENDIAN(TYPE) static INLINE2 TYPE UNUSED
 #  define EXTERN_SIM_ENDIAN_P 0
 # else
 #  define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED

Simon
Philippe Waroquiers via Gdb-patches June 19, 2021, 7:57 p.m. | #2
On 19 Jun 2021 10:39, Simon Marchi wrote:
> On 2021-06-18 1:21 a.m., Mike Frysinger via Gdb-patches wrote:

> > Move these options up to the common dir so we only test & export

> > them once across all ports.  It also enables -Werror usage on the

> > common files we've been pulling out of arch subdirs.

> 

> I get:

> 

> 

>   CC       common/common_libcommon_a-sim-load.o

> In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,

>                  from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,

>                  from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,

>                  from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,

>                  from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:

> /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: ‘offset_16’ defined but not used [-Werror=unused-function]

>    39 | #define offset_N XCONCAT2(offset_,N)

>       |                           ^~~~~~~

> /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro ‘CONCAT2’

>    23 | #define CONCAT2(a,b)     a##b

>       |                          ^

> /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro ‘XCONCAT2’

>    39 | #define offset_N XCONCAT2(offset_,N)

>       |                  ^~~~~~~~

> /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro ‘offset_N’

>   138 | offset_N (unsigned_N *x,

>       | ^~~~~~~~

> 

> This works:

> 

> 

> diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h

> index 2750fa93cbc7..cad36e796cbc 100644

> --- a/sim/common/sim-inline.h

> +++ b/sim/common/sim-inline.h

> @@ -445,7 +445,7 @@

>       && !defined (SIM_ENDIAN_C) \

>       && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))

>  # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)

> -#  define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED

> +#  define INLINE_SIM_ENDIAN(TYPE) static INLINE2 TYPE UNUSED

>  #  define EXTERN_SIM_ENDIAN_P 0

>  # else

>  #  define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED


the type is already marked UNUSED.  why isn't that working here ?

i tried to reproduce with -O0 but it's passing for me.
-mike
Philippe Waroquiers via Gdb-patches June 20, 2021, 1:33 a.m. | #3
> the type is already marked UNUSED.  why isn't that working here ?


Maybe because the UNUSED is after the TYPE, so it applies to the return
type, instead of to the function?  If I move UNUSED before TYPE, it
works.  I'll send a patch for that.

> i tried to reproduce with -O0 but it's passing for me.


It's gcc 11.1.0, if that matters.

Simon

Patch

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 79274beabd8d..8d5311456860 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -35,6 +35,7 @@  CLEANFILES =
 DISTCLEANFILES =
 MOSTLYCLEANFILES = core
 
+AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
 AM_CPPFLAGS = -I$(srcroot)/include
 
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS) $(CFLAGS_FOR_BUILD)
diff --git a/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in
index 9eae1f3e4998..6f9d4ad3c370 100644
--- a/sim/arch-subdir.mk.in
+++ b/sim/arch-subdir.mk.in
@@ -16,3 +16,6 @@ 
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index b82e76c91f6f..51e4ca7b5ac7 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -96,8 +96,6 @@  SIM_HW = @sim_hw@
 SIM_INLINE = @sim_inline@
 SIM_RESERVED_BITS = @sim_reserved_bits@
 SIM_SCACHE = @sim_scache@
-WARN_CFLAGS = @WARN_CFLAGS@
-WERROR_CFLAGS = @WERROR_CFLAGS@
 SIM_WARN_CFLAGS = $(WARN_CFLAGS)
 SIM_WERROR_CFLAGS = $(WERROR_CFLAGS)
 
diff --git a/sim/configure.ac b/sim/configure.ac
index 91af0bba5860..8e9190040d4c 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -117,6 +117,7 @@  SIM_AC_OPTION_ENVIRONMENT
 SIM_AC_OPTION_PROFILE
 SIM_AC_OPTION_STDIO
 SIM_AC_OPTION_TRACE
+SIM_AC_OPTION_WARNINGS
 
 AC_CONFIG_FILES([arch-subdir.mk Makefile])
 AC_OUTPUT
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index db6c3ffbbfe9..98385b99f76d 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -21,7 +21,6 @@  dnl one afterwards.  The two pieces of the common fragment are inserted into
 dnl the target's fragment at the appropriate points.
 AC_DEFUN([SIM_AC_OUTPUT],
 [dnl
-AC_REQUIRE([SIM_AC_OPTION_WARNINGS])dnl
 AC_REQUIRE([SIM_AC_OPTION_HARDWARE])dnl
 
 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.