From: Jan Kiszka <[email protected]> We already use this pattern for the inmate library. Moreover, our current pattern of generating build-in.o no longer works with 4.17. Switching to a library build is straightforward for arm and arm64, we just need more explicit rules on x86 because of the need to build two libraries in the same folder which is not directly supported by kbuild.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/Makefile | 7 +++---- hypervisor/arch/arm/Kbuild | 10 +++++----- hypervisor/arch/arm64/Kbuild | 6 +++--- hypervisor/arch/x86/Kbuild | 21 ++++++++++++++------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 1d809fd65..bc9884416 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -93,16 +93,15 @@ subdir-y := arch/$(SRCARCH) define BUILD_JAILHOUSE_template always += jailhouse$(1).bin -$$(obj)/arch/$$(SRCARCH)/built-in$(1).o: $$(obj)/arch/$$(SRCARCH) +$$(obj)/arch/$$(SRCARCH)/lib$(1).a: $$(obj)/arch/$$(SRCARCH) @true -hypervisor$(1)-y := arch/$$(SRCARCH)/built-in$(1).o $$(CORE_OBJECTS) \ - hypervisor.lds +hypervisor$(1)-y := arch/$$(SRCARCH)/lib$(1).a $$(CORE_OBJECTS) hypervisor.lds targets += $$(hypervisor$(1)-y) HYPERVISOR$(1)_OBJS = $$(addprefix $$(obj)/,$$(hypervisor$(1)-y)) -LDFLAGS_hypervisor$(1).o := -T +LDFLAGS_hypervisor$(1).o := --whole-archive -T targets += hypervisor$(1).o $$(obj)/hypervisor$(1).o: $$(src)/hypervisor.lds $$(HYPERVISOR$(1)_OBJS) diff --git a/hypervisor/arch/arm/Kbuild b/hypervisor/arch/arm/Kbuild index bdbb88ea2..839ea98d7 100644 --- a/hypervisor/arch/arm/Kbuild +++ b/hypervisor/arch/arm/Kbuild @@ -14,14 +14,14 @@ include $(src)/../arm-common/Kbuild KBUILD_AFLAGS := $(subst -include asm/unified.h,,$(KBUILD_AFLAGS)) -always := built-in.o +always := lib.a # units initialization order as defined by linking order: # irqchip (common-objs-y), [vexpress], <generic units> -obj-y := $(common-objs-y) -obj-y += entry.o setup.o control.o traps.o mmio.o lib.o -obj-y += mmu_hyp.o caches.o +lib-y := $(common-objs-y) +lib-y += entry.o setup.o control.o traps.o mmio.o lib.o +lib-y += mmu_hyp.o caches.o # in here we switch of the MMU and stuff, cant profile such code # NOTE @@ -29,4 +29,4 @@ obj-y += mmu_hyp.o caches.o # should switch to that for higher granularity, but gcc7 is not even there CFLAGS_mmu_hyp.o += -fno-profile-arcs -fno-test-coverage -obj-$(CONFIG_MACH_VEXPRESS) += vexpress.o +lib-$(CONFIG_MACH_VEXPRESS) += vexpress.o diff --git a/hypervisor/arch/arm64/Kbuild b/hypervisor/arch/arm64/Kbuild index d659392ba..b0ef924e5 100644 --- a/hypervisor/arch/arm64/Kbuild +++ b/hypervisor/arch/arm64/Kbuild @@ -14,10 +14,10 @@ include $(src)/../arm-common/Kbuild -always := built-in.o +always := lib.a # units initialization order as defined by linking order: # irqchip (common-objs-y), <generic units> -obj-y := $(common-objs-y) -obj-y += entry.o setup.o control.o mmio.o caches.o traps.o +lib-y := $(common-objs-y) +lib-y += entry.o setup.o control.o mmio.o caches.o traps.o diff --git a/hypervisor/arch/x86/Kbuild b/hypervisor/arch/x86/Kbuild index 8ab8d5636..84417621d 100644 --- a/hypervisor/arch/x86/Kbuild +++ b/hypervisor/arch/x86/Kbuild @@ -16,11 +16,7 @@ ccflags-$(CONFIG_JAILHOUSE_GCOV) += -fprofile-arcs -ftest-coverage -BUILT_IN_OBJECTS := built-in-amd.o built-in-intel.o - -always := $(BUILT_IN_OBJECTS) - -obj-y := $(BUILT_IN_OBJECTS) +always := lib-amd.a lib-intel.a common-objs-y := apic.o dbg-write.o entry.o setup.o control.o mmio.o iommu.o \ paging.o pci.o i8042.o vcpu.o vga.o ivshmem.o @@ -32,5 +28,16 @@ common-objs-y += ioapic.o common-objs-$(CONFIG_TEST_DEVICE) += test-device.o -built-in-amd-y := svm.o amd_iommu.o svm-vmexit.o $(common-objs-y) -built-in-intel-y := vmx.o vtd.o vmx-vmexit.o $(common-objs-y) cat.o +amd-objs := svm.o amd_iommu.o svm-vmexit.o $(common-objs-y) +intel-objs := vmx.o vtd.o vmx-vmexit.o $(common-objs-y) cat.o + +targets += $(amd-objs) $(intel-objs) + +quiet_cmd_link_archive = AR $@ +cmd_link_archive = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $^ + +$(obj)/lib-amd.a: $(addprefix $(obj)/,$(amd-objs)) + $(call if_changed,link_archive) + +$(obj)/lib-intel.a: $(addprefix $(obj)/,$(intel-objs)) + $(call if_changed,link_archive) -- 2.13.6 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
