public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 37/83] sim: modules.c: move generation to top-level
Date: Tue,  3 Jan 2023 02:55:19 -0500	[thread overview]
Message-ID: <20230103075605.13606-38-vapier@gentoo.org> (raw)
In-Reply-To: <20230103075605.13606-1-vapier@gentoo.org>

Now that all arches create libsim.a from the top-level, we have full
access to their inputs, and can move the actual generation from the
subdir up to the top-level.  This avoids recursive makes and will
help simplify state passing between the two.
---
 sim/Makefile.in           | 28 ++++++++++++++++++++++++----
 sim/common/Make-common.in | 25 +------------------------
 sim/common/local.mk       | 28 ++++++++++++++++++++++++----
 3 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index f9f6ed1984c4..15242c612647 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -159,28 +159,6 @@ test-hw-events: $(srccom)/hw-events.c libsim.a
 		$(CC) $(ALL_CFLAGS) -DMAIN -o test-hw-events$(EXEEXT) \
 		$(srccom)/hw-events.c libsim.a $(EXTRA_LIBS)
 
-# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
-modules.c: stamp-modules ; @true
-stamp-modules: Makefile
-	$(ECHO_STAMP) modules.c
-	$(SILENCE) LANG=C ; export LANG ; \
-	LC_ALL=C ; export LC_ALL ; \
-	sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $^ $(GEN_MODULES_C_SRCS) | sort >$@.l-tmp
-	@set -e; (\
-	echo '/* Do not modify this file.  */'; \
-	echo '/* It is created automatically by the Makefile.  */'; \
-	echo '#include "libiberty.h"'; \
-	echo '#include "sim-module.h"'; \
-	sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \
-	echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \
-	sed -e 's:\(.*\):  \1,:' $@.l-tmp; \
-	echo '};'; \
-	echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
-	) >$@.tmp
-	$(SILENCE) $(SHELL) $(srcroot)/move-if-change $@.tmp modules.c
-	$(SILENCE) rm -f $@.l-tmp $@.tmp
-	$(SILENCE) touch $@
-
 # Support targets.
 
 install:
@@ -214,8 +192,7 @@ TAGS: force
 		*.[ch] ../common/*.[ch]
 
 mostlyclean clean: $(SIM_EXTRA_CLEAN)
-	rm -f *.[oa] *~ core \
-		modules.c stamp-modules
+	rm -f *.[oa] *~ core
 
 distclean maintainer-clean realclean: clean
 	rm -f TAGS Makefile
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 128b770dbe10..debb55da933b 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -135,10 +135,30 @@ SIM_ALL_RECURSIVE_DEPS += $(%C%_HW_CONFIG_H_TARGETS)
 am_arch_d = $(subst -,_,$(@D))
 GEN_MODULES_C_SRCS = \
 	$(wildcard \
-		$(patsubst %.o,$(abs_srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \
-		$(filter-out %.o,$(patsubst $(@D)/%.o,$(abs_srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD))))
-%/modules.c:
-	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) GEN_MODULES_C_SRCS="$(GEN_MODULES_C_SRCS)" -C $(@D) $(@F)
+		$(patsubst %,$(srcdir)/%,$($(am_arch_d)_libsim_a_SOURCES)) \
+		$(patsubst %.o,$(srcdir)/%.c,$($(am_arch_d)_libsim_a_OBJECTS) $($(am_arch_d)_libsim_a_LIBADD)) \
+		$(filter-out %.o,$(patsubst $(@D)/%.o,$(srcdir)/common/%.c,$($(am_arch_d)_libsim_a_LIBADD))))
+%/modules.c: %/stamp-modules ; @true
+%/stamp-modules: Makefile
+	$(AM_V_GEN)set -e; \
+	LANG=C ; export LANG; \
+	LC_ALL=C ; export LC_ALL; \
+	sed -n -e '/^sim_install_/{s/^\(sim_install_[a-z_0-9A-Z]*\).*/\1/;p}' $(GEN_MODULES_C_SRCS) | sort >$@.l-tmp; \
+	( \
+	echo '/* Do not modify this file.  */'; \
+	echo '/* It is created automatically by the Makefile.  */'; \
+	echo '#include "libiberty.h"'; \
+	echo '#include "sim-module.h"'; \
+	sed -e 's:\(.*\):extern MODULE_INIT_FN \1;:' $@.l-tmp; \
+	echo 'MODULE_INSTALL_FN * const sim_modules_detected[] = {'; \
+	sed -e 's:\(.*\):  \1,:' $@.l-tmp; \
+	echo '};'; \
+	echo 'const int sim_modules_detected_len = ARRAY_SIZE (sim_modules_detected);'; \
+	) >$@.tmp; \
+	$(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/modules.c; \
+	rm -f $@.l-tmp; \
+	touch $@
+.PRECIOUS: %/stamp-modules
 
 ## NB: The ppc port doesn't currently utilize the modules API, so skip it.
 %C%_GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(filter-out ppc,$(SIM_ENABLED_ARCHES)))
-- 
2.39.0


  parent reply	other threads:[~2023-01-03  7:57 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03  7:54 [PATCH 00/83] sim: merge subdir makefiles into top-level Mike Frysinger
2023-01-03  7:54 ` [PATCH 01/83] sim: mips: add multi source to built sources Mike Frysinger
2023-01-03  7:54 ` [PATCH 02/83] sim: modules: trigger generation from top-level Mike Frysinger
2023-01-03  7:54 ` [PATCH 03/83] sim: build: drop support for subdir extra deps Mike Frysinger
2023-01-03  7:54 ` [PATCH 04/83] sim: aarch64: move libsim.a creation to top-level Mike Frysinger
2023-01-03  7:54 ` [PATCH 05/83] sim: arm: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 06/83] sim: avr: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 07/83] sim: bfin: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 08/83] sim: bpf: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 09/83] sim: cr16: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 10/83] sim: cris: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 11/83] sim: d10v: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 12/83] sim: erc32: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 13/83] sim: example-synacor: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 14/83] sim: frv: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 15/83] sim: ft32: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 16/83] sim: h8300: " Mike Frysinger
2023-01-03  7:54 ` [PATCH 17/83] sim: iq2000: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 18/83] sim: lm32: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 19/83] sim: m32c: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 20/83] sim: m32r: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 21/83] sim: m68hc11: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 22/83] sim: mcore: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 23/83] sim: microblaze: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 24/83] sim: mips: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 25/83] sim: mn10300: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 26/83] sim: moxie: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 27/83] sim: msp430: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 28/83] sim: or1k: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 29/83] sim: pru: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 30/83] sim: riscv: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 31/83] sim: rl78: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 32/83] sim: rx: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 33/83] sim: sh: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 34/83] sim: v850: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 35/83] sim: build: drop support for creating libsim.a in subdirs Mike Frysinger
2023-01-03  7:55 ` [PATCH 36/83] sim: build: drop common/nrun.o subdir hack Mike Frysinger
2023-01-03  7:55 ` Mike Frysinger [this message]
2023-01-03  7:55 ` [PATCH 38/83] sim: build: add basic framework for compiling arch objects in top-level Mike Frysinger
2023-01-03  7:55 ` [PATCH 39/83] sim: aarch64: move arch-specific file compilation to top-level Mike Frysinger
2023-01-03  7:55 ` [PATCH 40/83] sim: arm: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 41/83] sim: avr: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 42/83] sim: bpf: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 43/83] sim: bfin: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 44/83] sim: cr16: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 45/83] sim: cris: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 46/83] sim: d10v: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 47/83] sim: erc32: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 48/83] sim: example-synacor: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 49/83] sim: frv: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 50/83] sim: ft32: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 51/83] sim: h8300: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 52/83] sim: iq2000: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 53/83] sim: lm32: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 54/83] sim: m32c: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 55/83] sim: m32r: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 56/83] sim: m68hc11: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 57/83] sim: mcore: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 58/83] sim: microblaze: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 59/83] sim: mips: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 60/83] sim: mn10300: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 61/83] sim: moxie: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 62/83] sim: msp430: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 63/83] sim: or1k: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 64/83] sim: pru: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 65/83] sim: riscv: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 66/83] sim: rl78: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 67/83] sim: rx: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 68/83] sim: sh: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 69/83] sim: v850: " Mike Frysinger
2023-01-03  7:55 ` [PATCH 70/83] sim: move arch-specific file compilation of common/ files " Mike Frysinger
2023-01-03  7:55 ` [PATCH 71/83] sim: common: move test-hw-events to top-level build Mike Frysinger
2023-01-03  7:55 ` [PATCH 72/83] sim: disable recursive make in (most) subdirs Mike Frysinger
2023-01-03  7:55 ` [PATCH 73/83] sim: build: drop subdir Makefile.in files Mike Frysinger
2023-01-03  7:55 ` [PATCH 74/83] sim: build: delete Make-common.in logic Mike Frysinger
2023-01-03  7:55 ` [PATCH 75/83] sim: build: drop AM_MAKEFLAGS settings Mike Frysinger
2023-01-03  7:55 ` [PATCH 76/83] sim: common: simplify hw-config.h deps Mike Frysinger
2023-01-03  7:55 ` [PATCH 77/83] sim: igen: simplify build dep Mike Frysinger
2023-01-03  7:56 ` [PATCH 78/83] sim: common: move libcommon.a objects to sources Mike Frysinger
2023-01-03  7:56 ` [PATCH 79/83] sim: build: drop most recursive build deps Mike Frysinger
2023-01-03  7:56 ` [PATCH 80/83] sim: common: move libcommon.a dep to ppc code Mike Frysinger
2023-01-03  7:56 ` [PATCH 81/83] sim: common: move modules.c to source tracking Mike Frysinger
2023-01-03  7:56 ` [PATCH 82/83] sim: common: simplify modules.c deps Mike Frysinger
2023-01-03  7:56 ` [PATCH 83/83] sim: build: drop depdir subdir hack Mike Frysinger

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=20230103075605.13606-38-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).