mk: fix combined lib build with ABI versioning
authorFerruh Yigit <ferruh.yigit@intel.com>
Thu, 3 Dec 2015 13:51:08 +0000 (13:51 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 6 Dec 2015 14:41:04 +0000 (15:41 +0100)
Fixes following error (observed when versioning macros used):
  LD libdpdk.so
  /usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found
  for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:
$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
   <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
   <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
   <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...

Versioning fixed by merging all version scripts into one automatically and
feeding it to final library.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
MAINTAINERS
mk/rte.sharelib.mk
scripts/merge-maps.sh [new file with mode: 0755]

index 460245b..3afe84a 100644 (file)
@@ -54,6 +54,7 @@ F: scripts/auto-config-h.sh
 F: scripts/depdirs-rule.sh
 F: scripts/gen-build-mk.sh
 F: scripts/gen-config-h.sh
+F: scripts/merge-maps.sh
 F: scripts/relpath.sh
 F: doc/build-sdk-quick.txt
 F: doc/guides/prog_guide/build_app.rst
index 7bb7219..70c49a8 100644 (file)
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
 else
 LIB_ONE := lib$(RTE_LIBNAME).a
 endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+COMBINED_LDFLAGS += --version-script=$(COMBINED_MAP)
 endif
 
 .PHONY:sharelib
@@ -51,9 +53,10 @@ ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
 O_TO_S = $(LD) $(call linkerprefix,$(CPU_LDFLAGS)) \
+        $(call linkerprefix,$(COMBINED_LDFLAGS)) \
        -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 else
-O_TO_S = $(LD) $(CPU_LDFLAGS) \
+O_TO_S = $(LD) $(CPU_LDFLAGS) $(COMBINED_LDFLAGS) \
        -shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 endif
 
@@ -79,6 +82,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 $(LIB_ONE): FORCE
        @[ -d $(dir $@) ] || mkdir -p $(dir $@)
+       @$(SRCDIR)/scripts/merge-maps.sh > $(COMBINED_MAP)
        $(O_TO_S_DO)
 else
 $(LIB_ONE): FORCE
diff --git a/scripts/merge-maps.sh b/scripts/merge-maps.sh
new file mode 100755 (executable)
index 0000000..edc88de
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find "$RTE_SDK"/lib "$RTE_SDK"/drivers -name "*_version.map")
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
+
+first=0
+prev_sym="none"
+
+for s in $SYMBOLS; do
+       echo "$s {"
+       echo "    global:"
+       echo ""
+       for f in $FILES; do
+               sed -n "/$s {/,/}/p" "$f" | sed '/^$/d' | grep -v global | grep -v local | sed -e '1d' -e '$d'
+       done | sort -u
+       echo ""
+       if [ $first -eq 0 ]; then
+               first=1;
+               echo "    local: *;";
+       fi
+       if [ "$prev_sym" = "none" ]; then
+               echo "};";
+               prev_sym=$s;
+       else
+               echo "} $prev_sym;";
+               prev_sym=$s;
+       fi
+       echo ""
+done