mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 10:01:57 +00:00
mk: link core to library archive instead of .o file
Do not link base and core libraries into on large relocatable .o file, which is linked later to core - causing long link times. Create an independent library archive out of the base and core libraries that can be linked faster. issue #4027
This commit is contained in:
parent
64165d829e
commit
f68e655312
@ -1,4 +1,4 @@
|
||||
LIBS := core-fiasco
|
||||
CORE_OBJ := core-fiasco.o
|
||||
CORE_LIB := core-fiasco.a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -2,6 +2,6 @@ include $(REP_DIR)/etc/board.conf
|
||||
|
||||
TARGET := foc-$(BOARD)
|
||||
LIBS := core-foc
|
||||
CORE_OBJ := core-foc-$(BOARD).o
|
||||
CORE_LIB := core-foc-$(BOARD).a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,6 +1,6 @@
|
||||
BOARD ?= unknown
|
||||
TARGET := core_hw_$(BOARD)
|
||||
LIBS := core-hw-$(BOARD)
|
||||
CORE_OBJ := core-hw-$(BOARD).o
|
||||
CORE_LIB := core-hw-$(BOARD).a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,4 +1,4 @@
|
||||
LIBS := core-nova
|
||||
CORE_OBJ := core-nova.o
|
||||
CORE_LIB := core-nova.a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,4 +1,4 @@
|
||||
LIBS := core-okl4
|
||||
CORE_OBJ := core-okl4.o
|
||||
CORE_LIB := core-okl4.a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,4 +1,4 @@
|
||||
LIBS := core-pistachio
|
||||
CORE_OBJ := core-pistachio.o
|
||||
CORE_LIB := core-pistachio.a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,4 +1,4 @@
|
||||
LIBS := core-sel4
|
||||
CORE_OBJ := core-sel4.o
|
||||
CORE_LIB := core-sel4.a
|
||||
|
||||
include $(BASE_DIR)/src/core/target.inc
|
||||
|
@ -1,27 +1,43 @@
|
||||
TARGET ?= core
|
||||
CORE_OBJ ?= core.o
|
||||
CORE_LIB ?= core.a
|
||||
|
||||
$(TARGET):
|
||||
@true
|
||||
|
||||
ifneq ($(INSTALL_DIR),)
|
||||
ifneq ($(DEBUG_DIR),)
|
||||
$(TARGET): $(INSTALL_DIR)/$(CORE_OBJ) $(DEBUG_DIR)/$(CORE_OBJ)
|
||||
$(TARGET): $(INSTALL_DIR)/$(CORE_LIB) $(DEBUG_DIR)/$(CORE_LIB)
|
||||
|
||||
$(CORE_OBJ).stripped: $(CORE_OBJ)
|
||||
$(VERBOSE)$(STRIP) --strip-debug -o $@ $<
|
||||
$(CORE_LIB).stripped: $(CORE_LIB)
|
||||
$(VERBOSE)$(STRIP) --strip-unneeded -o $@ $<
|
||||
|
||||
$(INSTALL_DIR)/$(CORE_OBJ) : $(CORE_OBJ).stripped
|
||||
$(VERBOSE)ln -sf $(CURDIR)/$< $(INSTALL_DIR)/$(CORE_OBJ)
|
||||
$(INSTALL_DIR)/$(CORE_LIB) : $(CORE_LIB).stripped
|
||||
$(VERBOSE)ln -sf $(CURDIR)/$< $(INSTALL_DIR)/$(CORE_LIB)
|
||||
|
||||
$(DEBUG_DIR)/$(CORE_OBJ) : $(CORE_OBJ)
|
||||
$(VERBOSE)ln -sf $(CURDIR)/$< $(DEBUG_DIR)/$(CORE_OBJ)
|
||||
$(DEBUG_DIR)/$(CORE_LIB) : $(CORE_LIB)
|
||||
$(VERBOSE)ln -sf $(CURDIR)/$< $(DEBUG_DIR)/$(CORE_LIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: $(CORE_OBJ)
|
||||
$(CORE_OBJ):
|
||||
$(VERBOSE)$(LD) $(LD_MARCH) -u _start --whole-archive -r $(LINK_ITEMS) $(LIBCXX_GCC) -o $@
|
||||
#
|
||||
# Create an archive from base and core archive objects, this archive is
|
||||
# later linked to core. This gives better performance than the old way where we
|
||||
# would link the archives into a relocatable object file (ld -r) that in turn
|
||||
# was linked to core - leading to a large object file with many relocations
|
||||
# causing long link times (especially on base-hw)
|
||||
#
|
||||
# We create the archive by piping an MRI script to ar -M
|
||||
# "create " - create library
|
||||
# "addlib" - add $(LINK_ITEMS)
|
||||
# "save" - save and overwrite library
|
||||
.PHONY: $(CORE_LIB)
|
||||
$(CORE_LIB):
|
||||
$(VERBOSE)(echo "create $@"; \
|
||||
echo -e "$(addprefix \naddlib ,$(LINK_ITEMS))"; \
|
||||
echo "save"; \
|
||||
echo "end"; \
|
||||
) | $(AR) -M
|
||||
|
||||
|
||||
clean cleanall:
|
||||
$(VERBOSE)rm -f $(CORE_OBJ) $(CORE_OBJ).stripped
|
||||
$(VERBOSE)rm -f $(CORE_LIB) $(CORE_LIB).stripped
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-fiasco.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-fiasco.o" }
|
||||
proc binary_name_core_a { } { return "core-fiasco.a" }
|
||||
proc binary_name_timer { } { return "fiasco_timer_drv" }
|
||||
|
||||
proc kernel_files { } { return { fiasco sigma0-fiasco bootstrap-fiasco } }
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-foc.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-foc-[board].o" }
|
||||
proc binary_name_core_a { } { return "core-foc-[board].a" }
|
||||
proc binary_name_timer { } { return "foc_timer_drv" }
|
||||
|
||||
proc kernel_files { } { return { foc sigma0-foc bootstrap-foc } }
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-hw.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-hw.o" }
|
||||
proc binary_name_core_a { } { return "core-hw.a" }
|
||||
proc binary_name_timer { } { return "hw_timer_drv" }
|
||||
|
||||
|
||||
@ -49,14 +49,14 @@ proc run_boot_dir {binaries} {
|
||||
set ld_arg ""
|
||||
|
||||
if {![file exists [run_dir]/genode/ld.lib.so]} { set ld_arg lib/ld/hw }
|
||||
if {![file exists [run_dir]/genode/core-hw-[board].o]} { set core_arg core/hw }
|
||||
if {![file exists [run_dir]/genode/core-hw-[board].a]} { set core_arg core/hw }
|
||||
if {![file exists [run_dir]/genode/bootstrap-hw-[board].o]} { set bootstrap_arg bootstrap/hw }
|
||||
|
||||
set build_args "$bootstrap_arg $core_arg $ld_arg"
|
||||
if {[llength $build_args]} { build $build_args }
|
||||
|
||||
if {$ld_arg != ""} { file copy -force bin/ld-hw.lib.so [run_dir]/genode/ld.lib.so }
|
||||
if {$core_arg != ""} { file copy -force bin/core-hw-[board].o [run_dir]/genode/ }
|
||||
if {$core_arg != ""} { file copy -force bin/core-hw-[board].a [run_dir]/genode/ }
|
||||
if {$bootstrap_arg != ""} { file copy -force bin/bootstrap-hw-[board].o [run_dir]/genode/ }
|
||||
|
||||
#
|
||||
@ -68,12 +68,12 @@ proc run_boot_dir {binaries} {
|
||||
|
||||
puts "core link address is [core_link_address]"
|
||||
|
||||
set core_obj core-hw-[board].o
|
||||
set core_obj core-hw-[board].a
|
||||
set bootstrap_obj bootstrap-hw-[board].o
|
||||
|
||||
# create core and bootstrap binary without modules for debugging
|
||||
if {[file exists debug/core-hw-[board].o]} {
|
||||
build_core debug/core-hw-[board].o {} [run_dir].core [core_link_address]
|
||||
build_core debug/core-hw-[board].a {} [run_dir].core [core_link_address]
|
||||
build_core [run_dir]/genode/$bootstrap_obj {} [run_dir].bootstrap [bootstrap_link_address]
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-nova.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-nova.o" }
|
||||
proc binary_name_core_a { } { return "core-nova.a" }
|
||||
proc binary_name_timer { } { return "nova_timer_drv" }
|
||||
|
||||
proc kernel_files { } { return hypervisor }
|
||||
@ -36,14 +36,14 @@ proc run_boot_dir {binaries} {
|
||||
set core_arg ""
|
||||
set ld_arg ""
|
||||
if {![file exists [run_dir]/genode/hypervisor]} { set kernel_arg kernel }
|
||||
if {![file exists [run_dir]/genode/core-nova.o]} { set core_arg core/nova }
|
||||
if {![file exists [run_dir]/genode/core-nova.a]} { set core_arg core/nova }
|
||||
if {![file exists [run_dir]/genode/ld.lib.so]} { set ld_arg lib/ld/nova }
|
||||
|
||||
set targets "$kernel_arg $core_arg $ld_arg"
|
||||
if {[llength $targets]} { build $targets }
|
||||
|
||||
if {$kernel_arg != ""} { file copy -force bin/hypervisor [run_dir]/genode/hypervisor }
|
||||
if {$core_arg != ""} { file copy -force bin/core-nova.o [run_dir]/genode/core-nova.o }
|
||||
if {$core_arg != ""} { file copy -force bin/core-nova.a [run_dir]/genode/core-nova.a }
|
||||
if {$ld_arg != ""} { file copy -force bin/ld-nova.lib.so [run_dir]/genode/ld.lib.so }
|
||||
|
||||
#
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-okl4.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-okl4.o" }
|
||||
proc binary_name_core_a { } { return "core-okl4.a" }
|
||||
proc binary_name_timer { } { return "pit_timer_drv" }
|
||||
|
||||
proc kernel_files { } { return okl4 }
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-pistachio.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-pistachio.o" }
|
||||
proc binary_name_core_a { } { return "core-pistachio.a" }
|
||||
proc binary_name_timer { } { return "pit_timer_drv" }
|
||||
|
||||
proc kernel_files { } { return { pistachio sigma0-pistachio kickstart-pistachio } }
|
||||
|
@ -1,5 +1,5 @@
|
||||
proc binary_name_ld_lib_so { } { return "ld-sel4.lib.so" }
|
||||
proc binary_name_core_o { } { return "core-sel4.o" }
|
||||
proc binary_name_core_a { } { return "core-sel4.a" }
|
||||
proc binary_name_timer { } {
|
||||
if {[have_board imx6q_sabrelite]} { return "imx6_timer_drv" }
|
||||
if {[have_board imx7d_sabre]} { return "imx7_timer_drv" }
|
||||
|
@ -969,7 +969,7 @@ proc kernel_files { } { return { } }
|
||||
#
|
||||
proc build_core_image { modules } {
|
||||
|
||||
set core_obj [kernel_specific_binary core.o]
|
||||
set core_obj [kernel_specific_binary core.a]
|
||||
|
||||
# replace 'core' with actual core-object name in 'modules' list
|
||||
if {[lsearch $modules "core"] != -1} {
|
||||
|
Loading…
x
Reference in New Issue
Block a user