public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/5] sim: hw: rework configure option & device selection
@ 2021-06-20  5:55 Mike Frysinger
  2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

The sim-hardware configure option allows builders to select a set of
device models to enable.  But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece.  Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.

So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options.  Any ports
that have unique device models will declare them in their Makefile
instead of at configure time.  This will allow us to (eventually)
unify the setting into the common dir.
---
 sim/README-HACKING               |   4 +-
 sim/aarch64/configure            |  64 ++++++---------
 sim/arm/configure                |  64 ++++++---------
 sim/avr/configure                |  64 ++++++---------
 sim/bfin/Makefile.in             |  33 ++++++++
 sim/bfin/configure               | 136 +++++++++++--------------------
 sim/bfin/configure.ac            |  33 --------
 sim/bpf/configure                |  62 ++++++--------
 sim/common/Make-common.in        |  11 ++-
 sim/cr16/configure               |  64 ++++++---------
 sim/cris/Makefile.in             |   2 +
 sim/cris/configure               |  90 +++++++++-----------
 sim/cris/configure.ac            |   1 -
 sim/d10v/configure               |  64 ++++++---------
 sim/erc32/configure              |  64 ++++++---------
 sim/example-synacor/configure    |  64 ++++++---------
 sim/frv/configure                |  62 ++++++--------
 sim/ft32/configure               |  64 ++++++---------
 sim/h8300/configure              |  64 ++++++---------
 sim/iq2000/configure             |  62 ++++++--------
 sim/lm32/Makefile.in             |   2 +
 sim/lm32/configure               |  60 ++++++--------
 sim/lm32/configure.ac            |   1 -
 sim/m32c/configure               |  64 ++++++---------
 sim/m32r/Makefile.in             |   2 +
 sim/m32r/configure               |  61 ++++++--------
 sim/m32r/configure.ac            |   2 -
 sim/m4/sim_ac_option_hardware.m4 |  57 +++++--------
 sim/m4/sim_ac_output.m4          |   3 -
 sim/m68hc11/Makefile.in          |   2 +
 sim/m68hc11/configure            |  64 ++++++---------
 sim/m68hc11/configure.ac         |   4 -
 sim/mcore/configure              |  64 ++++++---------
 sim/microblaze/configure         |  64 ++++++---------
 sim/mips/Makefile.in             |   1 +
 sim/mips/configure               |  63 ++++++--------
 sim/mips/configure.ac            |   4 -
 sim/mn10300/Makefile.in          |   2 +
 sim/mn10300/configure            |  60 ++++++--------
 sim/mn10300/configure.ac         |   1 -
 sim/moxie/configure              |  64 ++++++---------
 sim/msp430/configure             |  64 ++++++---------
 sim/or1k/configure               |  62 ++++++--------
 sim/pru/configure                |  64 ++++++---------
 sim/riscv/configure              |  62 ++++++--------
 sim/rl78/configure               |  64 ++++++---------
 sim/rx/configure                 |  64 ++++++---------
 sim/sh/configure                 |  64 ++++++---------
 sim/v850/configure               |  62 ++++++--------
 49 files changed, 899 insertions(+), 1324 deletions(-)

diff --git a/sim/README-HACKING b/sim/README-HACKING
index 3715467337f7..9bb705e655eb 100644
--- a/sim/README-HACKING
+++ b/sim/README-HACKING
@@ -387,8 +387,8 @@ Hardware Devices
 ================
 
 The simplest simulator doesn't include hardware device support.  Once you're
-ready to move on to the next level, call the common macro in your configure.ac:
-SIM_AC_OPTION_HARDWARE(devone devtwo devthree)
+ready to move on to the next level, declare in your Makefile.in:
+SIM_EXTRA_HW_DEVICES = devone devtwo devthree
 
 The basic hardware API is documented in common/hw-device.h.
 
diff --git a/sim/bfin/Makefile.in b/sim/bfin/Makefile.in
index e3536158a2ad..57b9b5eb0625 100644
--- a/sim/bfin/Makefile.in
+++ b/sim/bfin/Makefile.in
@@ -26,6 +26,39 @@ SIM_OBJS = \
 	machs.o \
 	sim-resume.o
 
+SIM_EXTRA_HW_DEVICES = \
+	bfin_cec \
+	bfin_ctimer \
+	bfin_dma \
+	bfin_dmac \
+	bfin_ebiu_amc \
+	bfin_ebiu_ddrc \
+	bfin_ebiu_sdc \
+	bfin_emac \
+	bfin_eppi \
+	bfin_evt \
+	bfin_gpio \
+	bfin_gpio2 \
+	bfin_gptimer \
+	bfin_jtag \
+	bfin_mmu \
+	bfin_nfc \
+	bfin_otp \
+	bfin_pfmon \
+	bfin_pint \
+	bfin_pll \
+	bfin_ppi \
+	bfin_rtc \
+	bfin_sic \
+	bfin_spi \
+	bfin_trace \
+	bfin_twi \
+	bfin_uart \
+	bfin_uart2 \
+	bfin_wdog \
+	bfin_wp \
+	eth_phy
+
 SIM_EXTRA_CFLAGS = @SDL_CFLAGS@
 SIM_EXTRA_LIBS = @SDL_LIBS@ -lm
 
diff --git a/sim/bfin/configure.ac b/sim/bfin/configure.ac
index 4e31c6f13594..ab3bd5b0b99d 100644
--- a/sim/bfin/configure.ac
+++ b/sim/bfin/configure.ac
@@ -3,39 +3,6 @@ AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_DEFAULT_MODEL(bf537)
-SIM_AC_OPTION_HARDWARE(\
-	bfin_cec \
-	bfin_ctimer \
-	bfin_dma \
-	bfin_dmac \
-	bfin_ebiu_amc \
-	bfin_ebiu_ddrc \
-	bfin_ebiu_sdc \
-	bfin_emac \
-	bfin_eppi \
-	bfin_evt \
-	bfin_gpio \
-	bfin_gpio2 \
-	bfin_gptimer \
-	bfin_jtag \
-	bfin_mmu \
-	bfin_nfc \
-	bfin_otp \
-	bfin_pfmon \
-	bfin_pint \
-	bfin_pll \
-	bfin_ppi \
-	bfin_rtc \
-	bfin_sic \
-	bfin_spi \
-	bfin_trace \
-	bfin_twi \
-	bfin_uart \
-	bfin_uart2 \
-	bfin_wdog \
-	bfin_wp \
-	eth_phy \
-)
 
 PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES(SDL, sdl, [
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index ba62c32772c1..6d7c9c47b64a 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -73,8 +73,7 @@ SIM_BITSIZE = @sim_bitsize@
 SIM_DEFAULT_MODEL = @sim_default_model@
 SIM_FLOAT = @sim_float@
 SIM_HW_CFLAGS = @sim_hw_cflags@
-SIM_HW_OBJS = @sim_hw_objs@
-SIM_HW = @sim_hw@
+SIM_HW_SOCKSER = @sim_hw_sockser@
 SIM_RESERVED_BITS = @sim_reserved_bits@
 SIM_SCACHE = @sim_scache@
 SIM_WARN_CFLAGS = $(WARN_CFLAGS)
@@ -216,6 +215,10 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
+SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
+@SIM_ENABLE_HW_FALSE@SIM_HW_OBJS =
+
 ZLIB = $(zlibdir) -lz
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
 BFD_LIB = ../../bfd/libbfd.a
@@ -417,12 +420,12 @@ hw-config.h: stamp-hw ; @true
 stamp-hw: Makefile.in $(srccom)/Make-common.in config.status Makefile
 	rm -f tmp-hw.h
 	echo "/* generated by Makefile */" > tmp-hw.h
-	sim_hw="$(SIM_HW)"; \
+	sim_hw="$(SIM_HW_DEVICES)"; \
 	for hw in $$sim_hw ; do \
 	  echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
 	done >> tmp-hw.h
 	echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
-	sim_hw="$(SIM_HW)"; \
+	sim_hw="$(SIM_HW_DEVICES)"; \
 	for hw in $$sim_hw ; do \
 	  echo "  dv_$${hw}_descriptor," ; \
 	done >> tmp-hw.h
diff --git a/sim/cris/Makefile.in b/sim/cris/Makefile.in
index ef83ce818260..dfc6d6c5ac40 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -31,6 +31,8 @@ SIM_OBJS = \
 	$(CRISV32F_OBJS) \
 	traps.o
 
+SIM_EXTRA_HW_DEVICES = rv cris cris_900000xx
+
 # Extra headers included by sim-main.h.
 # FIXME: $(srccom)/cgen-ops.h should be in CGEN_INCLUDE_DEPS.
 SIM_EXTRA_DEPS = \
diff --git a/sim/cris/configure.ac b/sim/cris/configure.ac
index 13500a09a495..57a2d5fe3d7a 100644
--- a/sim/cris/configure.ac
+++ b/sim/cris/configure.ac
@@ -3,7 +3,6 @@ AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_SCACHE(16384)
-SIM_AC_OPTION_HARDWARE(rv cris cris_900000xx)
 
 # The default model shouldn't matter as long as there's a BFD.
 SIM_AC_OPTION_DEFAULT_MODEL(crisv32)
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 268882745c7e..bac9861ec53b 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -12,6 +12,8 @@ SIM_OBJS = \
         cpu.o decode.o sem.o model.o mloop.o \
         lm32.o traps.o user.o 
 
+SIM_EXTRA_HW_DEVICES = lm32cpu lm32timer lm32uart
+
 # List of extra dependencies.
 # Generally this consists of simulator specific files included by sim-main.h.
 SIM_EXTRA_DEPS = $(CGEN_INCLUDE_DEPS) $(srcdir)/../../opcodes/lm32-desc.h \
diff --git a/sim/lm32/configure.ac b/sim/lm32/configure.ac
index edf7968b3e04..96b6f0e98e25 100644
--- a/sim/lm32/configure.ac
+++ b/sim/lm32/configure.ac
@@ -4,6 +4,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(lm32)
-SIM_AC_OPTION_HARDWARE(lm32cpu lm32timer lm32uart)
 
 SIM_AC_OUTPUT
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index f8ccb97d77b0..eb9641ee8e67 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -34,6 +34,8 @@ SIM_OBJS = \
 	$(M32R2_OBJS) \
 	$(TRAPS_OBJ)
 
+SIM_EXTRA_HW_DEVICES = m32r_cache m32r_uart
+
 # Extra headers included by sim-main.h.
 SIM_EXTRA_DEPS = \
 	$(CGEN_INCLUDE_DEPS) \
diff --git a/sim/m32r/configure.ac b/sim/m32r/configure.ac
index a45eebdfedff..f98adb26c46d 100644
--- a/sim/m32r/configure.ac
+++ b/sim/m32r/configure.ac
@@ -18,6 +18,4 @@ SIM_AC_OPTION_DEFAULT_MODEL(m32r/d)
 AC_SUBST(traps_obj)
 AC_SUBST(sim_extra_cflags)
 
-SIM_AC_OPTION_HARDWARE(m32r_cache m32r_uart)
-
 SIM_AC_OUTPUT
diff --git a/sim/m4/sim_ac_option_hardware.m4 b/sim/m4/sim_ac_option_hardware.m4
index 477ab2669093..14101830e828 100644
--- a/sim/m4/sim_ac_option_hardware.m4
+++ b/sim/m4/sim_ac_option_hardware.m4
@@ -14,55 +14,42 @@ dnl You should have received a copy of the GNU General Public License
 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 dnl --enable-sim-hardware is for users of the simulator
-dnl arg[1] is a space separated list of extra target specific devices.
 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
-[
-hardware="cfi core pal glue [$1]"
-sim_hw_cflags="-DWITH_HW=1"
-sim_hw="$hardware"
-sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
-
+[dnl
+AC_MSG_CHECKING([for sim hardware settings])
 AC_ARG_ENABLE(sim-hardware,
-  [AS_HELP_STRING([--enable-sim-hardware=LIST],
-                  [Specify the hardware to be included in the build.])],
+  [AS_HELP_STRING([--enable-sim-hardware],
+		  [Whether to enable hardware/device simulation])],
   ,[enable_sim_hardware="yes"])
-case ${enable_sim_hardware} in
-  yes|no) ;;
-  ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
-  *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
-  *)  hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
-esac
-
+sim_hw_sockser=
 if test "$enable_sim_hardware" = no; then
-  sim_hw_objs=
   sim_hw_cflags="-DWITH_HW=0"
-  sim_hw=
-else
+elif test "$enable_sim_hardware" = yes; then
   sim_hw_cflags="-DWITH_HW=1"
-  # remove duplicates
-  sim_hw=""
-  sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
-  for i in $hardware ; do
-    case " $sim_hw " in
-      *" $i "*) ;;
-      *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
-    esac
-  done
   # mingw does not support sockser
   case ${host} in
     *mingw*) ;;
     *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
        # that you instatiate.  Instead, other code will call into it directly.
        # At some point, we should convert it over.
-       sim_hw_objs="$sim_hw_objs dv-sockser.o"
+       sim_hw_sockser="dv-sockser.o"
        sim_hw_cflags="$sim_hw_cflags -DHAVE_DV_SOCKSER"
        ;;
   esac
-  if test x"$silent" != x"yes"; then
-    echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
-  fi
+else
+  AC_MSG_ERROR([unknown argument "$enable_sim_hardware"])
 fi
-])
+dnl AM_CONDITIONAL([SIM_ENABLE_HW], [test "$enable_sim_hardware" = "yes"])
+if test "$enable_sim_hardware" = "yes"; then
+  SIM_ENABLE_HW_TRUE=
+  SIM_ENABLE_HW_FALSE='#'
+else
+  SIM_ENABLE_HW_TRUE='#'
+  SIM_ENABLE_HW_FALSE=
+fi
+AC_SUBST(SIM_ENABLE_HW_TRUE)
+AC_SUBST(SIM_ENABLE_HW_FALSE)
+AC_MSG_RESULT(${enable_sim_hardware})
 AC_SUBST(sim_hw_cflags)
-AC_SUBST(sim_hw_objs)
-AC_SUBST(sim_hw)
+AC_SUBST(sim_hw_sockser)
+])
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index 98385b99f76d..8d260421e0e9 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -51,9 +51,6 @@ AC_SUBST(sim_bitsize)
 AC_SUBST(sim_float)
 AC_SUBST(sim_scache)
 AC_SUBST(sim_default_model)
-AC_SUBST(sim_hw_cflags)
-AC_SUBST(sim_hw_objs)
-AC_SUBST(sim_hw)
 AC_SUBST(sim_reserved_bits)
 
 AC_OUTPUT
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index 8a044914ed65..e7b668648558 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -24,6 +24,8 @@ SIM_OBJS = $(M68HC11_OBJS) \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
+SIM_EXTRA_HW_DEVICES = m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram
+
 SIM_PROFILE= -DPROFILE=1 -DWITH_PROFILE=-1
 # We must use 32-bit addresses to support memory bank switching.
 # The WORD_BITSIZE is normally 16 but must be switched (temporarily)
diff --git a/sim/m68hc11/configure.ac b/sim/m68hc11/configure.ac
index 02eccf0ddcb7..99370b3a5770 100644
--- a/sim/m68hc11/configure.ac
+++ b/sim/m68hc11/configure.ac
@@ -2,8 +2,4 @@ dnl Process this file with autoconf to produce a configure script.
 AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
-dnl Options available in this module
-SIM_AC_OPTION_HARDWARE(\
-  m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram)
-
 SIM_AC_OUTPUT
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 2f79c56cbcbc..c04736ba0802 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -69,6 +69,7 @@ SIM_OBJS = \
 	sim-main.o \
 	sim-resume.o \
 
+SIM_EXTRA_HW_DEVICES = tx3904cpu tx3904irc tx3904tmr tx3904sio
 
 # List of flags to always pass to $(CC).
 SIM_SUBTARGET=@SIM_SUBTARGET@
diff --git a/sim/mips/configure.ac b/sim/mips/configure.ac
index a8c16b259251..e3a44a0055fa 100644
--- a/sim/mips/configure.ac
+++ b/sim/mips/configure.ac
@@ -400,9 +400,5 @@ AC_SUBST(sim_multi_flags)
 AC_SUBST(sim_multi_igen_configs)
 AC_SUBST(sim_multi_src)
 AC_SUBST(sim_multi_obj)
-#
-# Add simulated hardware devices
-#
-SIM_AC_OPTION_HARDWARE(tx3904cpu tx3904irc tx3904tmr tx3904sio)
 
 SIM_AC_OUTPUT
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index ba48273ba848..968378cafe62 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -25,6 +25,8 @@ MN10300_OBJS = \
 
 SIM_OBJS = $(MN10300_OBJS) interp.o
 
+SIM_EXTRA_HW_DEVICES = mn103cpu mn103int mn103tim mn103ser mn103iop
+
 SIM_EXTRA_CLEAN = clean-igen
 # Extra dependencies for "sim-main.h"
 SIM_EXTRA_DEPS = mn10300_sim.h itable.h idecode.h
diff --git a/sim/mn10300/configure.ac b/sim/mn10300/configure.ac
index e531be971cd7..74eb1fa54685 100644
--- a/sim/mn10300/configure.ac
+++ b/sim/mn10300/configure.ac
@@ -4,6 +4,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_RESERVED_BITS
 SIM_AC_OPTION_BITSIZE(32,31)
-SIM_AC_OPTION_HARDWARE(mn103cpu mn103int mn103tim mn103ser mn103iop)
 
 SIM_AC_OUTPUT
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/5] sim: unify hardware settings
  2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
@ 2021-06-20  5:55 ` Mike Frysinger
  2021-06-20  5:55 ` [PATCH 3/5] sim: drop configure scripts for simple ports Mike Frysinger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

Move these options up to the common dir so we only test & export
them once across all ports.
---
 sim/Makefile.in                  |  3 ++
 sim/aarch64/aclocal.m4           |  1 -
 sim/aarch64/configure            | 53 -------------------------------
 sim/aclocal.m4                   |  1 +
 sim/arch-subdir.mk.in            |  5 +++
 sim/arm/aclocal.m4               |  1 -
 sim/arm/configure                | 53 -------------------------------
 sim/avr/aclocal.m4               |  1 -
 sim/avr/configure                | 53 -------------------------------
 sim/bfin/aclocal.m4              |  1 -
 sim/bfin/configure               | 48 ----------------------------
 sim/bpf/aclocal.m4               |  1 -
 sim/bpf/configure                | 48 ----------------------------
 sim/common/Make-common.in        |  4 ---
 sim/configure                    | 54 ++++++++++++++++++++++++++++++--
 sim/configure.ac                 |  1 +
 sim/cr16/aclocal.m4              |  1 -
 sim/cr16/configure               | 53 -------------------------------
 sim/cris/aclocal.m4              |  1 -
 sim/cris/configure               | 48 ----------------------------
 sim/d10v/aclocal.m4              |  1 -
 sim/d10v/configure               | 53 -------------------------------
 sim/erc32/aclocal.m4             |  1 -
 sim/erc32/configure              | 53 -------------------------------
 sim/example-synacor/aclocal.m4   |  1 -
 sim/example-synacor/configure    | 53 -------------------------------
 sim/frv/aclocal.m4               |  1 -
 sim/frv/configure                | 48 ----------------------------
 sim/ft32/aclocal.m4              |  1 -
 sim/ft32/configure               | 53 -------------------------------
 sim/h8300/aclocal.m4             |  1 -
 sim/h8300/configure              | 53 -------------------------------
 sim/iq2000/aclocal.m4            |  1 -
 sim/iq2000/configure             | 48 ----------------------------
 sim/lm32/aclocal.m4              |  1 -
 sim/lm32/configure               | 48 ----------------------------
 sim/m32c/aclocal.m4              |  1 -
 sim/m32c/configure               | 53 -------------------------------
 sim/m32r/aclocal.m4              |  1 -
 sim/m32r/configure               | 48 ----------------------------
 sim/m4/sim_ac_option_hardware.m4 | 11 +------
 sim/m4/sim_ac_output.m4          |  2 --
 sim/m68hc11/aclocal.m4           |  1 -
 sim/m68hc11/configure            | 53 -------------------------------
 sim/mcore/aclocal.m4             |  1 -
 sim/mcore/configure              | 53 -------------------------------
 sim/microblaze/aclocal.m4        |  1 -
 sim/microblaze/configure         | 53 -------------------------------
 sim/mips/aclocal.m4              |  1 -
 sim/mips/configure               | 48 ----------------------------
 sim/mn10300/aclocal.m4           |  1 -
 sim/mn10300/configure            | 48 ----------------------------
 sim/moxie/aclocal.m4             |  1 -
 sim/moxie/configure              | 53 -------------------------------
 sim/msp430/aclocal.m4            |  1 -
 sim/msp430/configure             | 53 -------------------------------
 sim/or1k/aclocal.m4              |  1 -
 sim/or1k/configure               | 48 ----------------------------
 sim/pru/aclocal.m4               |  1 -
 sim/pru/configure                | 53 -------------------------------
 sim/riscv/aclocal.m4             |  1 -
 sim/riscv/configure              | 48 ----------------------------
 sim/rl78/aclocal.m4              |  1 -
 sim/rl78/configure               | 53 -------------------------------
 sim/rx/aclocal.m4                |  1 -
 sim/rx/configure                 | 48 ----------------------------
 sim/sh/aclocal.m4                |  1 -
 sim/sh/configure                 | 53 -------------------------------
 sim/v850/aclocal.m4              |  1 -
 sim/v850/configure               | 48 ----------------------------
 70 files changed, 63 insertions(+), 1627 deletions(-)

diff --git a/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in
index 92b217d20be6..f145f1a3c6bd 100644
--- a/sim/arch-subdir.mk.in
+++ b/sim/arch-subdir.mk.in
@@ -68,3 +68,8 @@ CGEN_MAINT = ; @true
 CGENDIR = @cgendir@
 
 SIM_INLINE = @SIM_INLINE@
+
+SIM_HW_CFLAGS = @sim_hw_cflags@
+SIM_HW_SOCKSER = @sim_hw_sockser@
+SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
+@SIM_ENABLE_HW_FALSE@SIM_HW_OBJS =
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 6d7c9c47b64a..41becaa05f16 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -72,8 +72,6 @@ SHELL = @SHELL@
 SIM_BITSIZE = @sim_bitsize@
 SIM_DEFAULT_MODEL = @sim_default_model@
 SIM_FLOAT = @sim_float@
-SIM_HW_CFLAGS = @sim_hw_cflags@
-SIM_HW_SOCKSER = @sim_hw_sockser@
 SIM_RESERVED_BITS = @sim_reserved_bits@
 SIM_SCACHE = @sim_scache@
 SIM_WARN_CFLAGS = $(WARN_CFLAGS)
@@ -216,8 +214,6 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
 SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
-SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
-@SIM_ENABLE_HW_FALSE@SIM_HW_OBJS =
 
 ZLIB = $(zlibdir) -lz
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
diff --git a/sim/configure.ac b/sim/configure.ac
index 9530268ddc59..042bfbfd1cd3 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -122,6 +122,7 @@ SIM_AC_OPTION_CGEN_MAINT
 SIM_AC_OPTION_DEBUG
 SIM_AC_OPTION_ENDIAN
 SIM_AC_OPTION_ENVIRONMENT
+SIM_AC_OPTION_HARDWARE
 SIM_AC_OPTION_INLINE
 SIM_AC_OPTION_PROFILE
 SIM_AC_OPTION_STDIO
diff --git a/sim/m4/sim_ac_option_hardware.m4 b/sim/m4/sim_ac_option_hardware.m4
index 14101830e828..ed53cd2f1206 100644
--- a/sim/m4/sim_ac_option_hardware.m4
+++ b/sim/m4/sim_ac_option_hardware.m4
@@ -39,16 +39,7 @@ elif test "$enable_sim_hardware" = yes; then
 else
   AC_MSG_ERROR([unknown argument "$enable_sim_hardware"])
 fi
-dnl AM_CONDITIONAL([SIM_ENABLE_HW], [test "$enable_sim_hardware" = "yes"])
-if test "$enable_sim_hardware" = "yes"; then
-  SIM_ENABLE_HW_TRUE=
-  SIM_ENABLE_HW_FALSE='#'
-else
-  SIM_ENABLE_HW_TRUE='#'
-  SIM_ENABLE_HW_FALSE=
-fi
-AC_SUBST(SIM_ENABLE_HW_TRUE)
-AC_SUBST(SIM_ENABLE_HW_FALSE)
+AM_CONDITIONAL([SIM_ENABLE_HW], [test "$enable_sim_hardware" = "yes"])
 AC_MSG_RESULT(${enable_sim_hardware})
 AC_SUBST(sim_hw_cflags)
 AC_SUBST(sim_hw_sockser)
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index 8d260421e0e9..aba45b0bc33e 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -21,8 +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_HARDWARE])dnl
-
 dnl Make @cgen_breaks@ non-null only if the sim uses CGEN.
 cgen_breaks=""
 if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/5] sim: drop configure scripts for simple ports
  2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
  2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
@ 2021-06-20  5:55 ` Mike Frysinger
  2021-06-23  1:05   ` Simon Marchi
  2021-06-20  5:55 ` [PATCH 4/5] sim: rx: merge with common configure script Mike Frysinger
  2021-06-20  5:55 ` [PATCH 5/5] sim: hw: move cfi & glue to common code Mike Frysinger
  3 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.

We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
---
 sim/Makefile.am                  |    2 +-
 sim/Makefile.in                  |   54 +-
 sim/aarch64/aclocal.m4           |   15 -
 sim/aarch64/configure            | 2873 ------------------------------
 sim/aarch64/configure.ac         |   25 -
 sim/arm/aclocal.m4               |   15 -
 sim/arm/configure                | 2873 ------------------------------
 sim/arm/configure.ac             |    5 -
 sim/avr/aclocal.m4               |   15 -
 sim/avr/configure                | 2873 ------------------------------
 sim/avr/configure.ac             |    5 -
 sim/bfin/configure               |    7 +
 sim/bpf/configure                |    7 +
 sim/common/Make-common.in        |   18 +-
 sim/configure                    |  465 ++++-
 sim/configure.ac                 |  108 +-
 sim/cr16/aclocal.m4              |   15 -
 sim/cr16/configure               | 2873 ------------------------------
 sim/cr16/configure.ac            |    5 -
 sim/cris/configure               |    7 +
 sim/d10v/aclocal.m4              |   15 -
 sim/d10v/configure               | 2873 ------------------------------
 sim/d10v/configure.ac            |    5 -
 sim/erc32/configure              |    7 +
 sim/example-synacor/aclocal.m4   |   15 -
 sim/example-synacor/configure    | 2873 ------------------------------
 sim/example-synacor/configure.ac |    5 -
 sim/frv/configure                |    7 +
 sim/ft32/aclocal.m4              |   15 -
 sim/ft32/configure               | 2873 ------------------------------
 sim/ft32/configure.ac            |    5 -
 sim/h8300/aclocal.m4             |   15 -
 sim/h8300/configure              | 2873 ------------------------------
 sim/h8300/configure.ac           |    5 -
 sim/iq2000/configure             |    7 +
 sim/lm32/configure               |    7 +
 sim/m32c/aclocal.m4              |   15 -
 sim/m32c/configure               | 2873 ------------------------------
 sim/m32c/configure.ac            |   24 -
 sim/m32r/configure               |    7 +
 sim/m4/sim_ac_output.m4          |    6 +
 sim/m68hc11/aclocal.m4           |   15 -
 sim/m68hc11/configure            | 2873 ------------------------------
 sim/m68hc11/configure.ac         |    5 -
 sim/mcore/aclocal.m4             |   15 -
 sim/mcore/configure              | 2873 ------------------------------
 sim/mcore/configure.ac           |    5 -
 sim/microblaze/aclocal.m4        |   15 -
 sim/microblaze/configure         | 2873 ------------------------------
 sim/microblaze/configure.ac      |    5 -
 sim/mips/configure               |    7 +
 sim/mn10300/configure            |    7 +
 sim/moxie/aclocal.m4             |   15 -
 sim/moxie/configure              | 2873 ------------------------------
 sim/moxie/configure.ac           |    5 -
 sim/msp430/aclocal.m4            |   15 -
 sim/msp430/configure             | 2873 ------------------------------
 sim/msp430/configure.ac          |   24 -
 sim/or1k/configure               |    7 +
 sim/pru/aclocal.m4               |   15 -
 sim/pru/configure                | 2873 ------------------------------
 sim/pru/configure.ac             |   24 -
 sim/riscv/configure              |    7 +
 sim/rl78/aclocal.m4              |   15 -
 sim/rl78/configure               | 2873 ------------------------------
 sim/rl78/configure.ac            |   24 -
 sim/rx/configure                 |    7 +
 sim/sh/aclocal.m4                |   15 -
 sim/sh/configure                 | 2873 ------------------------------
 sim/sh/configure.ac              |    5 -
 sim/v850/configure               |    7 +
 71 files changed, 638 insertions(+), 49390 deletions(-)
 delete mode 100644 sim/aarch64/aclocal.m4
 delete mode 100755 sim/aarch64/configure
 delete mode 100644 sim/aarch64/configure.ac
 delete mode 100644 sim/arm/aclocal.m4
 delete mode 100755 sim/arm/configure
 delete mode 100644 sim/arm/configure.ac
 delete mode 100644 sim/avr/aclocal.m4
 delete mode 100755 sim/avr/configure
 delete mode 100644 sim/avr/configure.ac
 delete mode 100644 sim/cr16/aclocal.m4
 delete mode 100755 sim/cr16/configure
 delete mode 100644 sim/cr16/configure.ac
 delete mode 100644 sim/d10v/aclocal.m4
 delete mode 100755 sim/d10v/configure
 delete mode 100644 sim/d10v/configure.ac
 delete mode 100644 sim/example-synacor/aclocal.m4
 delete mode 100755 sim/example-synacor/configure
 delete mode 100644 sim/example-synacor/configure.ac
 delete mode 100644 sim/ft32/aclocal.m4
 delete mode 100755 sim/ft32/configure
 delete mode 100644 sim/ft32/configure.ac
 delete mode 100644 sim/h8300/aclocal.m4
 delete mode 100755 sim/h8300/configure
 delete mode 100644 sim/h8300/configure.ac
 delete mode 100644 sim/m32c/aclocal.m4
 delete mode 100755 sim/m32c/configure
 delete mode 100644 sim/m32c/configure.ac
 delete mode 100644 sim/m68hc11/aclocal.m4
 delete mode 100755 sim/m68hc11/configure
 delete mode 100644 sim/m68hc11/configure.ac
 delete mode 100644 sim/mcore/aclocal.m4
 delete mode 100755 sim/mcore/configure
 delete mode 100644 sim/mcore/configure.ac
 delete mode 100644 sim/microblaze/aclocal.m4
 delete mode 100755 sim/microblaze/configure
 delete mode 100644 sim/microblaze/configure.ac
 delete mode 100644 sim/moxie/aclocal.m4
 delete mode 100755 sim/moxie/configure
 delete mode 100644 sim/moxie/configure.ac
 delete mode 100644 sim/msp430/aclocal.m4
 delete mode 100755 sim/msp430/configure
 delete mode 100644 sim/msp430/configure.ac
 delete mode 100644 sim/pru/aclocal.m4
 delete mode 100755 sim/pru/configure
 delete mode 100644 sim/pru/configure.ac
 delete mode 100644 sim/rl78/aclocal.m4
 delete mode 100755 sim/rl78/configure
 delete mode 100644 sim/rl78/configure.ac
 delete mode 100644 sim/sh/aclocal.m4
 delete mode 100755 sim/sh/configure
 delete mode 100644 sim/sh/configure.ac

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 1c5b276d4e97..24d07c84988a 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = -Im4 -I.. -I../config
 
 srcroot = $(srcdir)/..
 
-SUBDIRS = @subdirs@
+SUBDIRS = @subdirs@ $(SIM_SUBDIRS)
 
 SIM_PRIMARY_TARGET = @SIM_PRIMARY_TARGET@
 AM_MAKEFLAGS = SIM_PRIMARY_TARGET=$(SIM_PRIMARY_TARGET)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 41becaa05f16..4bf1e2e21e27 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -34,12 +34,15 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
-VPATH = @srcdir@:$(srccom)
 srcdir = @srcdir@
+VPATH = $(srcdir):$(srccom)
 srccom = $(srcdir)/../common
 srcroot = $(srcdir)/../..
 srcsim = $(srcdir)/..
 
+@SIM_COMMON_BUILD_FALSE@config.status = config.status
+@SIM_COMMON_BUILD_TRUE@config.status = ../config.status
+
 include $(srcroot)/gdb/silent-rules.mk
 
 # Helper code from gnulib.
@@ -413,7 +416,7 @@ endif
 
 # FIXME This is one very simple-minded way of generating the file hw-config.h
 hw-config.h: stamp-hw ; @true
-stamp-hw: Makefile.in $(srccom)/Make-common.in config.status Makefile
+stamp-hw: Makefile.in $(srccom)/Make-common.in $(config.status) Makefile
 	rm -f tmp-hw.h
 	echo "/* generated by Makefile */" > tmp-hw.h
 	sim_hw="$(SIM_HW_DEVICES)"; \
@@ -529,14 +532,15 @@ distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
 # Dummy target to force execution of dependent targets.
 force:
 
-Makefile: Makefile.in $(srccom)/Make-common.in config.status
-	CONFIG_HEADERS= $(SHELL) ./config.status
+Makefile: Makefile.in $(srccom)/Make-common.in $(config.status)
+@SIM_COMMON_BUILD_FALSE@	CONFIG_HEADERS= $(SHELL) ./config.status
+@SIM_COMMON_BUILD_TRUE@	cd .. && $(SHELL) ./config.status $(arch)/Makefile
 
-config.status: configure
-	$(SHELL) ./config.status --recheck
+@SIM_COMMON_BUILD_FALSE@config.status: configure
+@SIM_COMMON_BUILD_FALSE@	$(SHELL) ./config.status --recheck
 
 .gdbinit: # config.status $(srccom)/gdbinit.in
-	CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
+@SIM_COMMON_BUILD_FALSE@	CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
 
 
 # CGEN support
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index aba45b0bc33e..f9f70167e59c 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -51,5 +51,11 @@ AC_SUBST(sim_scache)
 AC_SUBST(sim_default_model)
 AC_SUBST(sim_reserved_bits)
 
+dnl Used by common/Make-common.in to see which configure script created it.
+SIM_COMMON_BUILD_TRUE='#'
+SIM_COMMON_BUILD_FALSE=
+AC_SUBST(SIM_COMMON_BUILD_TRUE)
+AC_SUBST(SIM_COMMON_BUILD_FALSE)
+
 AC_OUTPUT
 ])
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/5] sim: rx: merge with common configure script
  2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
  2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
  2021-06-20  5:55 ` [PATCH 3/5] sim: drop configure scripts for simple ports Mike Frysinger
@ 2021-06-20  5:55 ` Mike Frysinger
  2021-06-20  5:55 ` [PATCH 5/5] sim: hw: move cfi & glue to common code Mike Frysinger
  3 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

Move the unique configure flag to acinclude.m4 so the common code
can include it, then delete the rx configure logic entirely.
---
 sim/Makefile.in                       |    9 +-
 sim/configure                         |   49 +-
 sim/configure.ac                      |    5 +-
 sim/rx/Makefile.in                    |    2 +-
 sim/rx/{configure.ac => acinclude.m4} |   19 +-
 sim/rx/aclocal.m4                     |   15 -
 sim/rx/configure                      | 2909 -------------------------
 7 files changed, 61 insertions(+), 2947 deletions(-)
 rename sim/rx/{configure.ac => acinclude.m4} (74%)
 delete mode 100644 sim/rx/aclocal.m4
 delete mode 100755 sim/rx/configure

diff --git a/sim/configure.ac b/sim/configure.ac
index 5e5273570a5f..8c29a3433e67 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -129,7 +129,7 @@ if test "${enable_sim}" != no; then
     SIM_TARGET([pru*-*-*], [pru], [true])
     SIM_TARGET([riscv*-*-*], [riscv], [false])
     SIM_TARGET([rl78-*-*], [rl78], [true])
-    SIM_TARGET([rx-*-*], [rx], [false])
+    SIM_TARGET([rx-*-*], [rx], [true])
     SIM_TARGET([sh*-*-*], [sh], [true])
     SIM_TARGET([sparc-*-rtems*|sparc-*-elf*], [erc32], [false])
     SIM_TARGET([powerpc*-*-*], [ppc], [false])
@@ -167,5 +167,8 @@ AC_SUBST(sim_scache)
 AC_SUBST(sim_default_model)
 AC_SUBST(sim_reserved_bits)
 
+dnl Some arches have unique configure flags.
+m4_include([rx/acinclude.m4])
+
 AC_CONFIG_FILES([arch-subdir.mk Makefile])
 AC_OUTPUT
diff --git a/sim/rx/Makefile.in b/sim/rx/Makefile.in
index b1023dd2b9cf..5426cc0dd5d7 100644
--- a/sim/rx/Makefile.in
+++ b/sim/rx/Makefile.in
@@ -20,7 +20,7 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
-SIM_EXTRA_CFLAGS = @sim_rx_cycle_accurate_flags@
+SIM_EXTRA_CFLAGS = @SIM_RX_CYCLE_ACCURATE_FLAGS@
 
 SIM_RUN_OBJS = \
 	main.o \
diff --git a/sim/rx/configure.ac b/sim/rx/acinclude.m4
similarity index 74%
rename from sim/rx/configure.ac
rename to sim/rx/acinclude.m4
index 2f012f981487..b0df3a71dc9e 100644
--- a/sim/rx/configure.ac
+++ b/sim/rx/acinclude.m4
@@ -1,10 +1,5 @@
-dnl Process this file with autoconf to produce a configure script.
-
-dnl Copyright (C) 2005-2021 Free Software Foundation, Inc.
-dnl Contributed by Red Hat, Inc.
-dnl 
-dnl This file is part of the GNU simulators.
-dnl 
+dnl   Copyright (C) 1997-2021 Free Software Foundation, Inc.
+dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
 dnl the Free Software Foundation; either version 3 of the License, or
@@ -18,9 +13,7 @@ dnl
 dnl You should have received a copy of the GNU General Public License
 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
-AC_INIT(Makefile.in)
-AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
-
+dnl NB: This file is included in sim/configure, so keep settings namespaced.
 AC_MSG_CHECKING([whether sim rx should be cycle accurate])
 AC_ARG_ENABLE(sim-rx-cycle-accurate,
 [AS_HELP_STRING([--disable-sim-rx-cycle-accurate],
@@ -30,11 +23,9 @@ yes | no) ;;
 *)	AC_MSG_ERROR(bad value ${enableval} given for --enable-sim-rx-cycle-accurate option) ;;
 esac])
 if test "x${enable_sim_rx_cycle_accurate}" != xno; then
-  sim_rx_cycle_accurate_flags="-DCYCLE_ACCURATE"
+  SIM_RX_CYCLE_ACCURATE_FLAGS="-DCYCLE_ACCURATE"
   AC_MSG_RESULT([yes])
 else
   AC_MSG_RESULT([no])
 fi
-AC_SUBST(sim_rx_cycle_accurate_flags)
-
-SIM_AC_OUTPUT
+AC_SUBST(SIM_RX_CYCLE_ACCURATE_FLAGS)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/5] sim: hw: move cfi & glue to common code
  2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
                   ` (2 preceding siblings ...)
  2021-06-20  5:55 ` [PATCH 4/5] sim: rx: merge with common configure script Mike Frysinger
@ 2021-06-20  5:55 ` Mike Frysinger
  3 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

These don't depend on any arch state, so move them to the common
build code so we only build them once across all subdirs.
---
 sim/Makefile.in           | 61 +++++++++++++++++++++++++++++++--------
 sim/common/Make-common.in |  8 +++--
 sim/common/dv-cfi.c       |  2 +-
 sim/common/hw-base.h      |  2 ++
 sim/common/local.mk       |  6 ++++
 5 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 4bf1e2e21e27..2701462ba096 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -216,7 +216,8 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
-SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_DEVICES = core pal $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_DEVICES_COMMON = cfi glue
 
 ZLIB = $(zlibdir) -lz
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
@@ -228,6 +229,7 @@ EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
 	$(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)
 
 COMMON_OBJS_NAMES = \
+	$(SIM_HW_DEVICES_COMMON:%=dv-%.o) \
 	portability.o \
 	sim-load.o \
 	version.o
@@ -419,12 +421,12 @@ hw-config.h: stamp-hw ; @true
 stamp-hw: Makefile.in $(srccom)/Make-common.in $(config.status) Makefile
 	rm -f tmp-hw.h
 	echo "/* generated by Makefile */" > tmp-hw.h
-	sim_hw="$(SIM_HW_DEVICES)"; \
+	sim_hw="$(SIM_HW_DEVICES) $(SIM_HW_DEVICES_COMMON)"; \
 	for hw in $$sim_hw ; do \
 	  echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
 	done >> tmp-hw.h
 	echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
-	sim_hw="$(SIM_HW_DEVICES)"; \
+	sim_hw="$(SIM_HW_DEVICES) $(SIM_HW_DEVICES_COMMON)"; \
 	for hw in $$sim_hw ; do \
 	  echo "  dv_$${hw}_descriptor," ; \
 	done >> tmp-hw.h
diff --git a/sim/common/dv-cfi.c b/sim/common/dv-cfi.c
index 02a2cedd558b..008a3904771b 100644
--- a/sim/common/dv-cfi.c
+++ b/sim/common/dv-cfi.c
@@ -34,10 +34,10 @@
 #include <sys/mman.h>
 #endif
 
-#include "sim-main.h"
 #include "hw-base.h"
 #include "hw-main.h"
 #include "dv-cfi.h"
+#include "libiberty.h"
 
 /* Flashes are simple state machines, so here we cover all the
    different states a device might be in at any particular time.  */
diff --git a/sim/common/hw-base.h b/sim/common/hw-base.h
index f1cf989357b7..6980834c6874 100644
--- a/sim/common/hw-base.h
+++ b/sim/common/hw-base.h
@@ -23,6 +23,8 @@
 #ifndef HW_BASE
 #define HW_BASE
 
+struct sim_state;
+
 /* Create a primative device */
 
 struct hw *hw_create
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 25c7e5beb1f9..bc562c6e5e5e 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -38,6 +38,12 @@ noinst_LIBRARIES += %D%/libcommon.a
 	%D%/sim-load.c \
 	%D%/version.c
 
+if SIM_ENABLE_HW
+%C%_libcommon_a_SOURCES += \
+	%D%/dv-cfi.c \
+	%D%/dv-glue.c
+endif
+
 %D%/version.c: %D%/version.c-stamp ; @true
 %D%/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(srcdir)/%D%/create-version.sh
 	$(AM_V_GEN)$(SHELL) $(srcdir)/%D%/create-version.sh $(srcroot)/gdb $@.tmp
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/5] sim: drop configure scripts for simple ports
  2021-06-20  5:55 ` [PATCH 3/5] sim: drop configure scripts for simple ports Mike Frysinger
@ 2021-06-23  1:05   ` Simon Marchi
  2021-06-23  2:09     ` Mike Frysinger
  2021-06-23  2:59     ` [PATCH] sim: switch common srcdir to abs_srcdir Mike Frysinger
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Marchi @ 2021-06-23  1:05 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

On 2021-06-20 1:55 a.m., Mike Frysinger via Gdb-patches wrote:
> These ports only use the pieces that have been unified, so we can
> merge them into the common configure script and get rid of their
> unique one entirely.
> 
> We still compile & link separate run programs, and have dedicated
> subdir Makefiles, but the configure script portion is merged.

Starting with this patch (I think) the file sim/aarch64/Makefile gets
generated with a wrong srcdir value:

  srcdir = ..//home/simark/src/binutils-gdb/sim/aarch64

Which causes:

    make[2]: Entering directory '/home/simark/build/binutils-gdb/sim/aarch64'
    Makefile:34: ..//home/simark/src/binutils-gdb/sim/aarch64/../../gdb/silent-rules.mk: No such file or directory
    make[2]: *** No rule to make target '..//home/simark/src/binutils-gdb/sim/aarch64/../../gdb/silent-rules.mk'.  Stop.
    make[2]: Leaving directory '/home/simark/build/binutils-gdb/sim/aarch64'

That's strange.  I deleted sim/ completely and it still happens.  For
reference, here's my top-level configure line:

    .../configure 'CC=ccache gcc' 'CXX=ccache g++' '--with-system-readline' '--with-system-zlib' '--disable-gold' '--disable-ld' '--disable-gprof' '--disable-gas' '--enable-targets=all' '--with-expat=yes' '--with-python=python3' '--with-guile=guile-2.0' '--with-intel-pt' '--with-babeltrace' '--with-debuginfod' '--enable-libctf' 'CFLAGS=-g3 -O0 -fsanitize=address -fmax-errors=1 -fdiagnostics-color=always' 'CXXFLAGS=-g3 -O0 -fsanitize=address -D_GLIBCXX_DEBUG=1 -fmax-errors=1 -fdiagnostics-color=always' 'LDFLAGS=-fuse-ld=gold -fsanitize=address' '--enable-silent-rules'

Simon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/5] sim: drop configure scripts for simple ports
  2021-06-23  1:05   ` Simon Marchi
@ 2021-06-23  2:09     ` Mike Frysinger
  2021-06-23  2:59     ` [PATCH] sim: switch common srcdir to abs_srcdir Mike Frysinger
  1 sibling, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-23  2:09 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

On 22 Jun 2021 21:05, Simon Marchi wrote:
> On 2021-06-20 1:55 a.m., Mike Frysinger via Gdb-patches wrote:
> > These ports only use the pieces that have been unified, so we can
> > merge them into the common configure script and get rid of their
> > unique one entirely.
> > 
> > We still compile & link separate run programs, and have dedicated
> > subdir Makefiles, but the configure script portion is merged.
> 
> Starting with this patch (I think) the file sim/aarch64/Makefile gets
> generated with a wrong srcdir value:
> 
>   srcdir = ..//home/simark/src/binutils-gdb/sim/aarch64

it's def this patch.  i spent time digging through the docs to see if there
was a guarantee as to the value of srcdir (relative or absolute), but couldn't
find anything conclusive.  i guess it can be either :).

let me hack up something better here.
-mike

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] sim: switch common srcdir to abs_srcdir
  2021-06-23  1:05   ` Simon Marchi
  2021-06-23  2:09     ` Mike Frysinger
@ 2021-06-23  2:59     ` Mike Frysinger
  2021-06-23 13:01       ` Simon Marchi
  1 sibling, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2021-06-23  2:59 UTC (permalink / raw)
  To: gdb-patches

We rewrite srcdir in subdir Makefiles that we generate from the common
parent dir since it points to the parent dir.  Since @srcdir@ can be a
variety of formats (relative & absolute), switch to @abs_srcdir@ which
is a lot easier to adjust.  Our use of srcdir in here should handle it.
---
 sim/common/Make-common.in |  2 +-
 sim/configure             | 36 ++++++++++++++++++------------------
 sim/configure.ac          |  2 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 4bf1e2e21e27..c203b4e1c7bf 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -34,7 +34,7 @@
 
 ## COMMON_PRE_CONFIG_FRAG
 
-srcdir = @srcdir@
+srcdir = @abs_srcdir@
 VPATH = $(srcdir):$(srccom)
 srccom = $(srcdir)/../common
 srcroot = $(srcdir)/../..
diff --git a/sim/configure.ac b/sim/configure.ac
index e227f112d8b9..3632b559bf0f 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -69,7 +69,7 @@ m4_define([SIM_BUILD_TARGET], [dnl
     AC_CONFIG_COMMANDS([$1/Makefile],
 [sed -n \
 	-e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ {
-		/^srcdir / { s:= := ../:; s:$:/$1:; }
+		/^srcdir = / s:$:/$1:
 		p
 	}' \
 	<Make-common.sim >$1/Makesim1.tmp
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] sim: switch common srcdir to abs_srcdir
  2021-06-23  2:59     ` [PATCH] sim: switch common srcdir to abs_srcdir Mike Frysinger
@ 2021-06-23 13:01       ` Simon Marchi
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Marchi @ 2021-06-23 13:01 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches



On 2021-06-22 10:59 p.m., Mike Frysinger via Gdb-patches wrote:
> We rewrite srcdir in subdir Makefiles that we generate from the common
> parent dir since it points to the parent dir.  Since @srcdir@ can be a
> variety of formats (relative & absolute), switch to @abs_srcdir@ which
> is a lot easier to adjust.  Our use of srcdir in here should handle it.

That fixes it for me, thanks.

Simon

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-06-23 13:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
2021-06-20  5:55 ` [PATCH 3/5] sim: drop configure scripts for simple ports Mike Frysinger
2021-06-23  1:05   ` Simon Marchi
2021-06-23  2:09     ` Mike Frysinger
2021-06-23  2:59     ` [PATCH] sim: switch common srcdir to abs_srcdir Mike Frysinger
2021-06-23 13:01       ` Simon Marchi
2021-06-20  5:55 ` [PATCH 4/5] sim: rx: merge with common configure script Mike Frysinger
2021-06-20  5:55 ` [PATCH 5/5] sim: hw: move cfi & glue to common code Mike Frysinger

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).