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

[Minios-devel] [UNIKRAFT PATCH v4 1/4] build: Introduce symbols exporting for each library



In order to avoid symbol conflicts and relaxing on namespacing
of library-internal symbols, each library should provide
an `exportsyms.uk` file in its base directory. This file
lists the name of all symbols that should be exported
by the library, the rest is treated as internal symbol
which cannot be linked by another library. A warning is
thrown by `make` whenever this symbols file is absent.
The scope of each symbol for such a library stays unchanged.
This way, this patch won't break existing Unikraft projects
and libraries.

The location of this file can be overwritten by defining the
path with the [LIBNAME]_EXPORTS variable within the
appropriate `Makefile.uk`.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 support/build/Makefile.rules | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index e317e3d..35e2921 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -121,8 +121,9 @@ endef
 define addlib =
 $(call mk_sub_build_dir,$(1))
 UK_LIBS += $(1)
-$(eval $(call uc,$(1))_BASE  := $(_IMPORT_BASE))
-$(eval $(call uc,$(1))_BUILD := $(BUILD_DIR)/$(1))
+$(eval $(call uc,$(1))_BASE    := $(_IMPORT_BASE))
+$(eval $(call uc,$(1))_BUILD   := $(BUILD_DIR)/$(1))
+$(eval $(call uc,$(1))_EXPORTS := $(_IMPORT_BASE)/exportsyms.uk)
 endef
 
 # addlib_s $libname,$switch
@@ -136,9 +137,10 @@ endef
 # addplatlib $platname,$libname
 define addplatlib =
 $(call mk_sub_build_dir,$(2))
-$(eval $(call uc,$(1))_LIBS  += $(2))
-$(eval $(call uc,$(2))_BASE  := $(_IMPORT_BASE))
-$(eval $(call uc,$(2))_BUILD := $(BUILD_DIR)/$(2))
+$(eval $(call uc,$(1))_LIBS    += $(2))
+$(eval $(call uc,$(2))_BASE    := $(_IMPORT_BASE))
+$(eval $(call uc,$(2))_BUILD   := $(BUILD_DIR)/$(2))
+$(eval $(call uc,$(2))_EXPORTS := $(_IMPORT_BASE)/exportsyms.uk)
 endef
 
 # addplatlib_s $platname,$libname,$switch
@@ -412,6 +414,10 @@ endef
 
 # buildrule_olib $libname
 define buildrule_olib =
+$(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 build_cmd,LD,,$(call libname2preolib,$(1)),\
                $(LD) $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
@@ -419,9 +425,10 @@ $(call libname2preolib,$(1)): $($(call 
vprefix_lib,$(1),OBJS)) $($(call vprefix_
                      $($(call vprefix_lib,$(1),OBJS)) $($(call 
vprefix_lib,$(1),OBJS-y)) \
                      -o $(call libname2preolib,$(1)))
 
-$(call libname2olib,$(1)): $(call libname2preolib,$(1))
+$(call libname2olib,$(1)): $(call libname2preolib,$(1)) $(if $(wildcard 
$($(call vprefix_lib,$(1),EXPORTS))),$($(call vprefix_lib,$(1),EXPORTS)),)
        $(call build_cmd,OBJCOPY,,$(call libname2olib,$(1)),\
-               $(OBJCOPY) $(OBJCFLAGS) $(OBJCFLAGS-y) \
+               $(OBJCOPY) $(if $(wildcard $($(call 
vprefix_lib,$(1),EXPORTS))),--keep-global-symbols=$($(call 
vprefix_lib,$(1),EXPORTS)),) \
+                          $(OBJCFLAGS) $(OBJCFLAGS-y) \
                           $($(call vprefix_lib,$(1),OBJCFLAGS)) $($(call 
vprefix_lib,$(1),OBJCFLAGS-y)) \
                           $(call libname2preolib,$(1)) $(call 
libname2olib,$(1)))
 
-- 
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®.