public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: modules.c: move generation to top-level
@ 2023-01-10  6:25 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2023-01-10  6:25 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=54e26255ca9e1e39b1c5d091809c3afe350c3d01

commit 54e26255ca9e1e39b1c5d091809c3afe350c3d01
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Nov 6 16:56:39 2022 +0700

    sim: modules.c: move generation to top-level
    
    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.

Diff:
---
 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/Makefile.in b/sim/Makefile.in
index 0a2f4a991ee..839e6e17e27 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -1853,8 +1853,9 @@ common_HW_CONFIG_H_TARGETS = $(patsubst %,%/hw-config.h,$(SIM_ENABLED_ARCHES))
 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))))
+		$(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))))
 
 common_GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(filter-out ppc,$(SIM_ENABLED_ARCHES)))
 LIBIBERTY_LIB = ../libiberty/libiberty.a
@@ -4539,8 +4540,27 @@ common/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(src
 	$(SHELL) $(srcroot)/move-if-change $@.tmp $(@D)/hw-config.h; \
 	touch $@
 .PRECIOUS: %/stamp-hw
-%/modules.c:
-	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) GEN_MODULES_C_SRCS="$(GEN_MODULES_C_SRCS)" -C $(@D) $(@F)
+%/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
 
 # Alias for developers.
 @SIM_ENABLE_IGEN_TRUE@igen: $(IGEN)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index f9f6ed1984c..15242c61264 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 128b770dbe1..debb55da933 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)))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-10  6:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10  6:25 [binutils-gdb] sim: modules.c: move generation to top-level Michael 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).