aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-11-06 16:56:39 +0700
committerMike Frysinger <vapier@gentoo.org>2022-11-11 01:44:16 +0700
commit267058274c08c2df61d5f83a5f1d864eee2ccf34 (patch)
treec918faede180d7b9d341cd772d96431abbb757f1
parent007b6af6e18810a408aac4132134037b4dc8d206 (diff)
downloadgdb-267058274c08c2df61d5f83a5f1d864eee2ccf34.zip
gdb-267058274c08c2df61d5f83a5f1d864eee2ccf34.tar.gz
gdb-267058274c08c2df61d5f83a5f1d864eee2ccf34.tar.bz2
sim: modules.c: move generation to top-level
In order to compile arch objects from the top-level, we need to generate the modules.c file, so move that logic up to the top level first. The deps are a bit imperfect currently due to the common/ files not being shared. That'll improve as we share the sources more.
-rw-r--r--sim/aarch64/local.mk5
-rw-r--r--sim/common/Make-common.in27
-rw-r--r--sim/common/local.mk31
3 files changed, 31 insertions, 32 deletions
diff --git a/sim/aarch64/local.mk b/sim/aarch64/local.mk
index bbcf592..62095f7 100644
--- a/sim/aarch64/local.mk
+++ b/sim/aarch64/local.mk
@@ -47,6 +47,5 @@ $(%C%_libsim_a_OBJECTS) $(%C%_run_OBJECTS) $(%C%_libsim_a_LIBADD): | $(SIM_ALL_R
%D%/%.o: common/%.c | $(SIM_ALL_RECURSIVE_DEPS)
$(AM_V_CC)$(COMPILE) -c -o $@ $<
-# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
-#%D%/modules.c: %D%/stamp-modules ; @true
-#%D%/stamp-modules: Makefile $(%C%_libsim_a_SOURCES) ; $(DO_MODULES_C)
+%D%/modules.c: %D%/stamp-modules ; @true
+%D%/stamp-modules: Makefile $(%C%_libsim_a_SOURCES) ; $(GEN_MODULES_C)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 1b32841..96dd6de 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -196,9 +196,7 @@ override POSTCOMPILE =
endif
all_object_files = $(LIB_OBJS) $(SIM_RUN_OBJS)
-generated_files = \
- $(SIM_EXTRA_DEPS) \
- modules.c
+generated_files = $(SIM_EXTRA_DEPS)
# Ensure that generated files are created early. Use order-only
# dependencies if available. They require GNU make 3.80 or newer,
@@ -217,28 +215,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 $(SIM_OBJS:.o=.c)
- $(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}' $^ | 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:
@@ -274,7 +250,6 @@ TAGS: force
mostlyclean clean: $(SIM_EXTRA_CLEAN)
rm -f *.[oa] *~ core \
run$(EXEEXT) libsim.a \
- modules.c stamp-modules \
tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 29b1970..07ca04b 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -51,9 +51,6 @@ noinst_LIBRARIES += $(SIM_COMMON_LIB)
CLEANFILES += \
%D%/version.c %D%/version.c-stamp
-%/modules.c:
- $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
-
##
## For subdirs.
##
@@ -133,6 +130,34 @@ endif
MOSTLYCLEANFILES += $(%C%_HW_CONFIG_H_TARGETS) $(patsubst %,%/stamp-hw,$(SIM_ENABLED_ARCHES))
SIM_ALL_RECURSIVE_DEPS += $(%C%_HW_CONFIG_H_TARGETS)
+# See sim_pre_argv_init and sim_module_install in sim-module.c for more details.
+GEN_MODULES_C_SRCS = \
+ $(wildcard \
+ $(patsubst %.o,$(srcdir)/%.c,$($(@D)_libsim_a_OBJECTS) $($(@D)_libsim_a_LIBADD)) \
+ $(patsubst $(@D)/%.o,$(srcdir)/common/%.c,$($(@D)_libsim_a_LIBADD)))
+GEN_MODULES_C = \
+ $(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 $@
+GEN_MODULES_C_TARGETS = $(patsubst %,%/modules.c,$(SIM_SUBDIRS))
+MOSTLYCLEANFILES += $(GEN_MODULES_C_TARGETS) $(patsubst %,%/stamp-moules,$(SIM_SUBDIRS))
+SIM_ALL_RECURSIVE_DEPS += $(GEN_MODULES_C_TARGETS)
+
LIBIBERTY_LIB = ../libiberty/libiberty.a
BFD_LIB = ../bfd/libbfd.la
OPCODES_LIB = ../opcodes/libopcodes.la