@@ -13,6 +13,12 @@ QEMU_CFLAGS += -I../linux-headers
endif
QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
+ifeq ($(TARGET_BASE_ARCH), multi)
+ARCH_DIRS=$(MULTI_BASE_TARGETS)
+else
+ARCH_DIRS=$(TARGET_BASE_ARCH)
+endif
+
QEMU_CFLAGS+=-I$(SRC_PATH)/include
ifdef CONFIG_USER_ONLY
@@ -84,15 +90,18 @@ all: $(PROGS) stap
#########################################################
# cpu emulator library
-obj-y = exec.o translate-all.o cpu-exec.o
+obj-y += exec.o
+arch-obj-$(call lnot,$(TARGET_MULTI)) += translate-all.o
obj-y += translate-common.o
+arch-obj-$(call lnot,$(TARGET_MULTI)) += cpu-exec.o
obj-y += cpu-exec-common.o
-obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
-obj-$(CONFIG_TCG_INTERPRETER) += tci.o
+arch-obj-$(call lnot,$(TARGET_MULTI)) += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
+arch-obj-$(call land,$(CONFIG_TCG_INTERPRETER),$(call lnot,$(TARGET_MULTI))) += tci.o
obj-y += tcg/tcg-common.o
obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
obj-y += fpu/softfloat.o
-obj-y += target-$(TARGET_BASE_ARCH)/
+arch-obj-y += target-$(TARGET_BASE_ARCH)/
+obj-y += $(foreach a, $(ARCH_DIRS), target-$(a)/hw/)
obj-y += disas.o
obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
@@ -135,7 +144,8 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
obj-y += qtest.o bootdevice.o
obj-y += hw/
obj-$(CONFIG_KVM) += kvm-all.o
-obj-y += memory.o cputlb.o
+obj-y += memory.o
+arch-obj-$(call lnot,$(TARGET_MULTI)) += cputlb.o
obj-y += memory_mapping.o
obj-y += dump.o
obj-y += migration/ram.o migration/savevm.o
@@ -151,7 +161,7 @@ obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
ifeq ($(TARGET_NAME), sparc64)
obj-y += hw/sparc64/
else
-obj-y += hw/$(TARGET_BASE_ARCH)/
+obj-y += $(foreach a, $(ARCH_DIRS), hw/$(a)/)
endif
GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
@@ -162,6 +172,17 @@ endif # CONFIG_SOFTMMU
%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
dummy := $(call unnest-vars,,obj-y)
+dummy := $(call unnest-vars,,arch-obj-y)
+
+arch-obj.o: $(arch-obj-y)
+ $(call quiet-command,$(LD) $(filter-out %.mak, $^) -r -o $@,"LINK $@")
+ $(call quiet-command,$(OBJCOPY) -w -L "*" $@,"OBJCOPY $@")
+
+.PHONY: .FORCE
+
+%/arch-obj.o: .FORCE
+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" arch-obj.o,)
+
all-obj-y := $(obj-y)
target-obj-y :=
@@ -178,6 +199,8 @@ dummy := $(call unnest-vars,.., \
target-obj-y := $(target-obj-y-save)
all-obj-y += $(common-obj-y)
all-obj-y += $(target-obj-y)
+all-obj-y += $(arch-obj-y)
+all-obj-y += $(foreach a, $(MULTI_TARGETS), ../$(a)/arch-obj.o)
all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
$(QEMU_PROG_BUILD): config-devices.mak
@@ -1,4 +1,4 @@
-obj-$(CONFIG_SOFTMMU) += machine.o
-obj-y += translate.o helper.o cpu.o
-obj-y += int_helper.o fpu_helper.o vax_helper.o sys_helper.o mem_helper.o
-obj-y += gdbstub.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o
+arch-obj-y += translate.o helper.o cpu.o
+arch-obj-y += int_helper.o fpu_helper.o vax_helper.o sys_helper.o mem_helper.o
+arch-obj-y += gdbstub.o
@@ -1,3 +1,3 @@
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o
+arch-obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
@@ -1,7 +1,7 @@
-obj-y += translate.o helper.o cpu.o
-obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
-obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
-obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
-obj-$(CONFIG_KVM) += kvm.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
+arch-obj-y += translate.o helper.o cpu.o
+arch-obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
+arch-obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
+arch-obj-y += gdbstub.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
+arch-obj-$(CONFIG_KVM) += kvm.o
+arch-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
@@ -1,4 +1,4 @@
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += gdbstub.o
-obj-y += lm32-semi.o
-obj-$(CONFIG_SOFTMMU) += machine.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o
+arch-obj-y += lm32-semi.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o
@@ -1,3 +1,3 @@
-obj-y += m68k-semi.o
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += gdbstub.o
+arch-obj-y += m68k-semi.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o
@@ -1,4 +1,4 @@
-obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o
-obj-y += gdbstub.o msa_helper.o mips-semi.o
-obj-$(CONFIG_SOFTMMU) += machine.o
-obj-$(CONFIG_KVM) += kvm.o
+arch-obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o msa_helper.o mips-semi.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o
+arch-obj-$(CONFIG_KVM) += kvm.o
@@ -1,2 +1,2 @@
-obj-y += translate.o helper.o machine.o cpu.o machine.o
-obj-$(CONFIG_SOFTMMU) += mmu.o
+arch-obj-y += translate.o helper.o machine.o cpu.o machine.o
+arch-obj-$(CONFIG_SOFTMMU) += mmu.o
@@ -1,5 +1,5 @@
-obj-$(CONFIG_SOFTMMU) += machine.o
-obj-y += cpu.o exception.o interrupt.o mmu.o translate.o
-obj-y += exception_helper.o fpu_helper.o int_helper.o \
+arch-obj-$(CONFIG_SOFTMMU) += machine.o
+arch-obj-y += cpu.o exception.o interrupt.o mmu.o translate.o
+arch-obj-y += exception_helper.o fpu_helper.o int_helper.o \
interrupt_helper.o mmu_helper.o sys_helper.o
-obj-y += gdbstub.o
+arch-obj-y += gdbstub.o
@@ -1,17 +1,17 @@
-obj-y += cpu-models.o
-obj-y += translate.o
+arch-obj-y += cpu-models.o
+arch-obj-y += translate.o
ifeq ($(CONFIG_SOFTMMU),y)
-obj-y += machine.o mmu_helper.o mmu-hash32.o
-obj-$(TARGET_PPC64) += mmu-hash64.o arch_dump.o
+arch-obj-y += machine.o mmu_helper.o mmu-hash32.o
+arch-obj-$(TARGET_PPC64) += mmu-hash64.o arch_dump.o
endif
-obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
-obj-y += dfp_helper.o
-obj-y += excp_helper.o
-obj-y += fpu_helper.o
-obj-y += int_helper.o
-obj-y += timebase_helper.o
-obj-y += misc_helper.o
-obj-y += mem_helper.o
-obj-$(CONFIG_USER_ONLY) += user_only_helper.o
-obj-y += gdbstub.o
+arch-obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
+arch-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
+arch-obj-y += dfp_helper.o
+arch-obj-y += excp_helper.o
+arch-obj-y += fpu_helper.o
+arch-obj-y += int_helper.o
+arch-obj-y += timebase_helper.o
+arch-obj-y += misc_helper.o
+arch-obj-y += mem_helper.o
+arch-obj-$(CONFIG_USER_ONLY) += user_only_helper.o
+arch-obj-y += gdbstub.o
@@ -1,5 +1,5 @@
-obj-y += translate.o helper.o cpu.o interrupt.o
-obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
-obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o
-obj-$(CONFIG_KVM) += kvm.o
+arch-obj-y += translate.o helper.o cpu.o interrupt.o
+arch-obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
+arch-obj-y += gdbstub.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o mmu_helper.o
+arch-obj-$(CONFIG_KVM) += kvm.o
@@ -1,2 +1,2 @@
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += gdbstub.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o
@@ -1,7 +1,7 @@
-obj-$(CONFIG_SOFTMMU) += machine.o
-obj-y += translate.o helper.o cpu.o
-obj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
-obj-$(TARGET_SPARC) += int32_helper.o
-obj-$(TARGET_SPARC64) += int64_helper.o
-obj-$(TARGET_SPARC64) += vis_helper.o
-obj-y += gdbstub.o
+arch-obj-$(CONFIG_SOFTMMU) += machine.o
+arch-obj-y += translate.o helper.o cpu.o
+arch-obj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
+arch-obj-$(TARGET_SPARC) += int32_helper.o
+arch-obj-$(TARGET_SPARC64) += int64_helper.o
+arch-obj-$(TARGET_SPARC64) += vis_helper.o
+arch-obj-y += gdbstub.o
@@ -1 +1 @@
-obj-y += translate.o helper.o cpu.o op_helper.o
+arch-obj-y += translate.o helper.o cpu.o op_helper.o
@@ -1,4 +1,4 @@
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += ucf64_helper.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += ucf64_helper.o
-obj-$(CONFIG_SOFTMMU) += softmmu.o
+arch-obj-$(CONFIG_SOFTMMU) += softmmu.o
@@ -1,6 +1,6 @@
-obj-y += xtensa-semi.o
-obj-y += core-dc232b.o
-obj-y += core-dc233c.o
-obj-y += core-fsf.o
-obj-y += translate.o op_helper.o helper.o cpu.o
-obj-y += gdbstub.o
+arch-obj-y += xtensa-semi.o
+arch-obj-y += core-dc232b.o
+arch-obj-y += core-dc233c.o
+arch-obj-y += core-fsf.o
+arch-obj-y += translate.o op_helper.o helper.o cpu.o
+arch-obj-y += gdbstub.o
Add a new *obj- category, arch-obj. arch-obj-y will be a subset of the existing obj-y. The difference, is arch-obj components are usable by multi-arch builds. That is, following the single-arch target builds, the already-built arch_obj components for multiple targets can be linked together to form a multi-arch build that supports multi CPU archs. Such a link is likely to have high numbers of namespace collisions. So if the target arch supports multi-arch build, localise all symbols to a single pre-linked object. The object does not need to export any APIs, as all APIs are made available via QOM CPU hooks. This forms a prerequisite for multi-arch support that there is no definitions of symbols by arch-obj for use by core code. target-foo is converted to arch-obj. But some CPUs may still need to export APIs to device land (hw/). An example of this is the ARM co-processor register interface. Such fns can be split off to new C files in target-foo/hw dir where they remain obj-y for global visibility. This creates a clearer separation of which functions are system global and which are private to the CPU. Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> --- Changed since RFCv2 Convert all arches to arch-obj straight up. Remove CONFIG_ARCH_SINGLE --- Makefile.target | 35 +++++++++++++++++++++++++++++------ target-alpha/Makefile.objs | 8 ++++---- target-cris/Makefile.objs | 6 +++--- target-i386/Makefile.objs | 14 +++++++------- target-lm32/Makefile.objs | 8 ++++---- target-m68k/Makefile.objs | 6 +++--- target-mips/Makefile.objs | 8 ++++---- target-moxie/Makefile.objs | 4 ++-- target-openrisc/Makefile.objs | 8 ++++---- target-ppc/Makefile.objs | 30 +++++++++++++++--------------- target-s390x/Makefile.objs | 10 +++++----- target-sh4/Makefile.objs | 4 ++-- target-sparc/Makefile.objs | 14 +++++++------- target-tricore/Makefile.objs | 2 +- target-unicore32/Makefile.objs | 6 +++--- target-xtensa/Makefile.objs | 12 ++++++------ 16 files changed, 99 insertions(+), 76 deletions(-)