[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH] build: Support for static libraries



Hi Simon,

The patch looks good, just some typos in the commit message (see below).
Other than that:

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>


Thanks,

— Felipe



On 10/18/18, 11:29 AM, "Simon Kuenzer" <simon.kuenzer@xxxxxxxxx> wrote:

>Introduce support for linking (externally built) static libraries.
>
>A static library can be registered at three different places:

s/at/in

> * [LIBNAME]_ALIBS and [LIBNAME]_ALIBS-y
>   static libraries used when (pre-)linking a library object
> * [PLATNAME]_ALIBS and [PLATNAME]_ALIBS-y
>   static libraries that are linked at the final linking step but only
>   for a specific platform
> * UK_ALIBS and UK_ALIBS-y
>   static libraries that are linked at the final linking step
>
>While the link order of object files is irrelevant to the linker,
>static libraries are handled differently. During linking, static
>libraries are only visited once. Only objects from these libraries are
>taken that solve at least one yet unresolved symbol. Because of this,

“The only objects taken are those that resolve at least one unresolved
symbol”.

>we populate the list of static libraries right after populating all
>relevant object files.
>
>Any order or circular dependency within a group the static libraries

s/the/of

>is resolved by instructing the linker to scan the archives multiple
>times. This is done by the --start-group and --end-group linker flags.
>
>With this change, we also remove the UK_LINK and UK_LINK-y variables
>that were used to simplify the platform's linker scripts. Because of
>the link order and additional linker flags, we directly assemble the
>linker command by taken the items from the corresponding OLIBS and
>ALIBS lists.
>
>Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
>---
> Makefile                     |  2 --
> plat/kvm/Linker.uk           | 13 ++++++++++---
> plat/linuxu/Linker.uk        | 14 ++++++++++++--
> plat/xen/Linker.uk           | 13 ++++++++++---
> support/build/Makefile.build |  3 ---
> support/build/Makefile.rules | 15 ++++++++++++---
> 6 files changed, 44 insertions(+), 16 deletions(-)
>
>diff --git a/Makefile b/Makefile
>index 96be2db..1e2d035 100644
>--- a/Makefile
>+++ b/Makefile
>@@ -188,8 +188,6 @@ UK_ALIBS:=
> UK_ALIBS-y:=
> UK_OLIBS:=
> UK_OLIBS-y:=
>-UK_LINK:=
>-UK_LINK-y:=
> UK_SRCS:=
> UK_SRCS-y:=
> UK_DEPS:=
>diff --git a/plat/kvm/Linker.uk b/plat/kvm/Linker.uk
>index daf2efe..e0a5677 100644
>--- a/plat/kvm/Linker.uk
>+++ b/plat/kvm/Linker.uk
>@@ -13,12 +13,19 @@ endif
> ##
> KVM_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_kvm-$(CONFIG_UK_ARCH)
> 
>-$(KVM_IMAGE): $(KVM_LINK) $(KVM_LINK-y) $(UK_LINK) $(UK_LINK-y)
>$(KVM_LDSCRIPT)
>+$(KVM_IMAGE): $(KVM_ALIBS) $(KVM_ALIBS-y) $(KVM_OLIBS) $(KVM_OLIBS-y) \
>+              $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) \
>+              $(KVM_LDSCRIPT)
>       $(call build_cmd,LD,,$@.ld.o,\
>              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
>                       $(KVM_LDFLAGS) $(KVM_LDFLAGS-y) \
>-                      $(KVM_LINK) $(KVM_LINK-y) \
>-                      $(UK_LINK) $(UK_LINK-y) -o $@.ld.o)
>+                      $(KVM_OLIBS) $(KVM_OLIBS-y) \
>+                      $(UK_OLIBS) $(UK_OLIBS-y) \
>+                      -Wl$(comma)--start-group \
>+                      $(KVM_ALIBS) $(KVM_ALIBS-y) \
>+                      $(UK_ALIBS) $(UK_ALIBS-y) \
>+                      -Wl$(comma)--end-group \
>+                      -o $@.ld.o)
>       $(call build_cmd,OBJCOPY,,$@.o,\
>              $(OBJCOPY) -w -G kvmos_* -G _libkvmplat_entry $@.ld.o $@.o)
> ifneq ($(filter x86_64 arm64,$(CONFIG_UK_ARCH)),)
>diff --git a/plat/linuxu/Linker.uk b/plat/linuxu/Linker.uk
>index abef585..9e4b2a9 100644
>--- a/plat/linuxu/Linker.uk
>+++ b/plat/linuxu/Linker.uk
>@@ -5,9 +5,19 @@ LINUXU_LDFLAGS-y += -Wl,-e,_liblinuxuplat_start
> ##
> LINUXU_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_linuxu-$(CONFIG_UK_ARCH)
> 
>-$(LINUXU_IMAGE): $(LINUXU_LINK) $(LINUXU_LINK-y) $(UK_LINK) $(UK_LINK-y)
>+$(LINUXU_IMAGE): $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
>+               $(LINUXU_OLIBS) $(LINUXU_OLIBS-y) \
>+               $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
>       $(call build_cmd,LD,,$@,\
>-             $(LD) $(LDFLAGS) $(LDFLAGS-y) $(LINUXU_LDFLAGS)
>$(LINUXU_LDFLAGS-y) $^ -o $@)
>+             $(LD) $(LDFLAGS) $(LDFLAGS-y) \
>+                   $(LINUXU_LDFLAGS) $(LINUXU_LDFLAGS-y) \
>+                   $(LINUXU_OLIBS) $(LINUXU_OLIBS-y) \
>+                   $(UK_OLIBS) $(UK_OLIBS-y) \
>+                   -Wl$(comma)--start-group \
>+                   $(LINUXU_ALIBS) $(LINUXU_ALIBS-y) \
>+                   $(UK_ALIBS) $(UK_ALIBS-y) \
>+                   -Wl$(comma)--end-group \
>+                   -o $@)
> ifeq ($(CONFIG_OPTIMIZE_DBGFILE),y)
>       $(call build_cmd,OBJCOPY,,$@.dbg,\
>              $(OBJCOPY) --only-keep-debug $@ $@.dbg)
>diff --git a/plat/xen/Linker.uk b/plat/xen/Linker.uk
>index 55c27fd..df84c20 100644
>--- a/plat/xen/Linker.uk
>+++ b/plat/xen/Linker.uk
>@@ -18,12 +18,19 @@ endif
> ##
> XEN_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_xen-$(CONFIG_UK_ARCH)
> 
>-$(XEN_IMAGE): $(XEN_LINK) $(XEN_LINK-y) $(UK_LINK) $(UK_LINK-y)
>$(XEN_LDSCRIPT)
>+$(XEN_IMAGE): $(XEN_ALIBS) $(XEN_ALIBS-y) $(XEN_OLIBS) $(XEN_OLIBS-y) \
>+              $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y) \
>+              $(XEN_LDSCRIPT)
>       $(call build_cmd,LD,,$@.ld.o,\
>              $(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
>                       $(XEN_LDFLAGS) $(XEN_LDFLAGS-y) \
>-                      $(XEN_LINK) $(XEN_LINK-y) \
>-                      $(UK_LINK) $(UK_LINK-y) -o $@.ld.o)
>+                      $(XEN_OLIBS) $(XEN_OLIBS-y) \
>+                      $(UK_OLIBS) $(UK_OLIBS-y) \
>+                      -Wl$(comma)--start-group \
>+                      $(XEN_ALIBS) $(XEN_ALIBS-y) \
>+                      $(UK_ALIBS) $(UK_ALIBS-y) \
>+                      -Wl$(comma)--end-group \
>+                      -o $@.ld.o)
>       $(call build_cmd,OBJCOPY,,$@.o,\
>              $(OBJCOPY) -w -G xenos_* -G _libxenplat_start $@.ld.o $@.o)
> ifeq (arm,$(CONFIG_UK_ARCH))
>diff --git a/support/build/Makefile.build b/support/build/Makefile.build
>index e65861e..5679741 100644
>--- a/support/build/Makefile.build
>+++ b/support/build/Makefile.build
>@@ -35,8 +35,6 @@ $(eval UK_OLIBS-y += $(call libname2olib,$(L))); \
> )
> endif
> 
>-UK_LINK-y += $(UK_OLIBS-y)
>-
> 
> #################################################
> #
>@@ -57,6 +55,5 @@ $(eval $(call uc,$(P))_OLIBS-y    += $(call
>libname2olib,$(L))); \
> ) \
> ) \
> ); \
>-$(eval $(call uc,$(P))_LINK-y += $($(call uc,$(P))_OLIBS-y)) \
> )
> endif
>diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
>index 687ef98..36fb8db 100644
>--- a/support/build/Makefile.rules
>+++ b/support/build/Makefile.rules
>@@ -489,11 +489,20 @@ $(if $(wildcard $($(call
>vprefix_lib,$(1),EXPORTS))),,\
>       $(warning Warning: Definition of exported symbols for $(1) missing:
>$($(call vprefix_lib,$(1),EXPORTS))) \
> )
> 
>-$(call libname2preolib,$(1)): $($(call vprefix_lib,$(1),OBJS)) $($(call
>vprefix_lib,$(1),OBJS-y))
>+$(call libname2preolib,$(1)): $($(call vprefix_lib,$(1),OBJS)) \
>+                            $($(call vprefix_lib,$(1),OBJS-y)) \
>+                            $($(call vprefix_lib,$(1),ALIBS)) \
>+                            $($(call vprefix_lib,$(1),ALIBS-y))
>       $(call build_cmd,LD,,$(call libname2preolib,$(1)),\
>               $(LD) $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
>-                    $($(call vprefix_lib,$(1),LDFLAGS)) $($(call
>vprefix_lib,$(1),LDFLAGS-y)) \
>-                    $($(call vprefix_lib,$(1),OBJS)) $($(call
>vprefix_lib,$(1),OBJS-y)) \
>+                    $($(call vprefix_lib,$(1),LDFLAGS)) \
>+                    $($(call vprefix_lib,$(1),LDFLAGS-y)) \
>+                    $($(call vprefix_lib,$(1),OBJS)) \
>+                    $($(call vprefix_lib,$(1),OBJS-y)) \
>+                    -Wl$(comma)--start-group \
>+                    $($(call vprefix_lib,$(1),ALIBS)) \
>+                    $($(call vprefix_lib,$(1),ALIBS-y)) \
>+                    -Wl$(comma)--end-group \
>                     -o $(call libname2preolib,$(1)))
> 
> $(call libname2olib,$(1)): $(call libname2preolib,$(1)) $(if $(wildcard
>$($(call vprefix_lib,$(1),EXPORTS))),$($(call vprefix_lib,$(1),EXPORTS)),)
>-- 
>2.7.4
>

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.