[PATCH/committed,2/5] sim: ppc: move libsim.a creation to top-level

Message ID 20240103062132.24338-2-vapier@gentoo.org
State New
Headers
Series [PATCH/committed,1/5] sim: ppc: move main.o compilation to top-level |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply

Commit Message

Mike Frysinger Jan. 3, 2024, 6:21 a.m. UTC
  The objects are still compiled in the subdir, but the creation of the
archive itself is in the top-level.  This is a required step before we
can move compilation itself up, and makes it easier to review.

The downside is that each object compile is a recursive make instead of
a single one.  It adds some overhead, so it's not great, but it shouldn't
be a big deal.  This will go away once compilation is hoisted up.
---
 sim/Makefile.in     | 111 ++++++++++++++++++++++++++++++++++++--------
 sim/configure       |   1 -
 sim/configure.ac    |   1 -
 sim/ppc/Makefile.in |   9 +---
 sim/ppc/local.mk    |  54 ++++++++++++++++++---
 5 files changed, 141 insertions(+), 35 deletions(-)
  

Patch

diff --git a/sim/configure.ac b/sim/configure.ac
index bc51492fd478..cd84040945b7 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -64,7 +64,6 @@  m4_define([SIM_BUILD_TARGET], [dnl
   AS_VAR_APPEND([SIM_ENABLED_ARCHES], [" $1"])
   m4_if($2, [true], [dnl
     AC_CONFIG_FILES($1/Makefile)
-    subdirs="$subdirs $1"
   ])
   AC_CONFIG_FILES($1/.gdbinit:common/gdbinit.in)
 ])
diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in
index 7841e75d4ce8..8c055689e6e1 100644
--- a/sim/ppc/Makefile.in
+++ b/sim/ppc/Makefile.in
@@ -97,10 +97,7 @@  INCLUDES	= -I. -I$(srcdir) $(LIB_INCLUDES) $(BFD_INCLUDES) -I../..
 LIBIBERTY_LIB	= ../../libiberty/libiberty.a
 BFD_LIB		= ../../bfd/libbfd.la
 
-
-TARGETLIB	= libsim.a
-
-all:	$(TARGETLIB) $(GDB_OBJ)
+all:
 
 .c.o:
 	$(ECHO_CC) $(CC) -c $(STD_CFLAGS) $<
@@ -444,10 +441,6 @@  PACKAGE_SRC = pk_disklabel.c
 PACKAGE_OBJ = $(PACKAGE_SRC:.c=.o)
 
 
-$(TARGETLIB): defines.h $(LIB_OBJ) $(GDB_OBJ)
-	$(ECHO_AR) $(AR) $(AR_FLAGS) $(TARGETLIB) $(LIB_OBJ) $(GDB_OBJ)
-	$(ECHO_RANLIB) $(RANLIB) $(TARGETLIB)
-
 psim.o: psim.c $(CPU_H) $(IDECODE_H) $(OPTIONS_H) $(TREE_H) $(BFD_H)
 
 bits.o: bits.c $(BASICS_H)
diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk
index 3c36b60df5a4..90f9489e4644 100644
--- a/sim/ppc/local.mk
+++ b/sim/ppc/local.mk
@@ -26,6 +26,53 @@  AM_CPPFLAGS_%C% = \
 	$(sim_ppc_model) $(sim_ppc_default_model) $(sim_ppc_model_issue) \
 	$(sim_ppc_switch)
 
+%C%_libsim_a_SOURCES = \
+	$(common_libcommon_a_SOURCES)
+%C%_libsim_a_LIBADD = \
+	%D%/debug.o \
+	%D%/bits.o \
+	%D%/sim-endian.o \
+	%D%/os_emul.o \
+	%D%/emul_generic.o \
+	%D%/emul_bugapi.o \
+	%D%/emul_chirp.o \
+	%D%/emul_netbsd.o \
+	%D%/emul_unix.o \
+	%D%/registers.o \
+	%D%/vm.o \
+	%D%/corefile.o \
+	%D%/model.o \
+	%D%/spreg.o \
+	%D%/cpu.o \
+	%D%/interrupts.o \
+	%D%/events.o \
+	%D%/cap.o \
+	%D%/device.o \
+	%D%/tree.o \
+	%D%/device_table.o \
+	%D%/itable.o \
+	%D%/mon.o \
+	%D%/icache.o \
+	%D%/semantics.o \
+	%D%/idecode.o \
+	%D%/support.o \
+	%D%/sim-fpu.o \
+	%D%/psim.o \
+	%D%/pk_disklabel.o \
+	$(patsubst %,%D%/%,$(sim_ppc_hw_obj)) \
+	%D%/options.o \
+	%D%/gdb-sim.o \
+	%D%/sim_calls.o
+
+noinst_LIBRARIES += %D%/libsim.a
+
+## common/sim-endian.c is matched before ppc/sim-endian.c due to the pattern
+## rule below.  Force the ppc version until we can unify the two properly.
+%D%/sim-endian.o: $(srcdir)/%D%/sim-endian.c ; $(SIM_COMPILE)
+
+%D%/%.o: common/%.c ; $(SIM_COMPILE)
+-@am__include@ %D%/$(DEPDIR)/*.Po
+
 %C%_run_SOURCES = \
 	%D%/main.c
 %C%_run_LDADD = \
@@ -34,13 +81,11 @@  AM_CPPFLAGS_%C% = \
 
 ## This makes sure common parts are available before building the arch-subdirs
 ## which will refer to these.
-SIM_ALL_RECURSIVE_DEPS += common/libcommon.a
-%D%/libsim.a: common/libcommon.a
+%D%/%.o: %D%/%.c | common/libcommon.a %D%/defines.h %D%/stamp-igen %D%/hw.c %D%/hw.h
 	$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
 
 noinst_PROGRAMS += %D%/run
 
-SIM_ALL_RECURSIVE_DEPS += %D%/defines.h
 %D%/defines.h: %D%/stamp-defines ; @true
 %D%/stamp-defines: config.h Makefile
 	$(AM_V_GEN)sed -n -e '/^#define HAVE_/s/ 1$$/",/' -e '/^#define HAVE_/s//"HAVE_/p' < config.h > %D%/defines.hin
@@ -120,7 +165,6 @@  BUILT_SOURCES += \
 	$(%C%_BUILT_SRC_FROM_IGEN) \
 	%D%/stamp-igen
 
-SIM_ALL_RECURSIVE_DEPS += %D%/stamp-igen
 $(%C%_BUILT_SRC_FROM_IGEN): %D%/stamp-igen
 
 %C%_IGEN_OPCODE_RULES = %D%/@sim_ppc_opcode@
@@ -224,7 +268,6 @@  BUILT_SOURCES += \
 	%D%/hw.c \
 	%D%/hw.h \
 	%D%/stamp-hw
-SIM_ALL_RECURSIVE_DEPS += %D%/stamp-hw
 %D%/hw.c %D%/hw.h: %D%/stamp-igen
 
 ## Real packages
@@ -249,7 +292,6 @@  $(srcdir)/%D%/pk.h: @MAINT@ %D%/stamp-pk ; @true
 	$(AM_V_at)touch $@
 
 %C%_BUILD_OUTPUTS += %D%/stamp-pk
-SIM_ALL_RECURSIVE_DEPS += %D%/stamp-pk
 
 %C%docdir = $(docdir)/%C%
 %C%doc_DATA = %D%/BUGS %D%/INSTALL %D%/README %D%/RUN