* [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
@ 2015-12-03 1:22 Ferruh Yigit
2015-12-03 1:36 ` Thomas Monjalon
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 1:22 UTC (permalink / raw)
To: dev
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>
---
drivers/net/Makefile | 3 +++
lib/Makefile | 3 +++
mk/rte.sdkbuild.mk | 2 +-
mk/rte.sharelib.mk | 3 +++
scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
5 files changed, 39 insertions(+), 1 deletion(-)
create mode 100755 scripts/merge_maps.sh
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index cddcd57..d3c865b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+ifeq ($(COMBINED_BUILD),1)
include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/lib/Makefile b/lib/Makefile
index ef172ea..d0f7fb8 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
endif
+ifeq ($(COMBINED_BUILD),1)
include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
index 38ec7bd..d4e3abf 100644
--- a/mk/rte.sdkbuild.mk
+++ b/mk/rte.sdkbuild.mk
@@ -94,7 +94,7 @@ $(ROOTDIRS-y):
@echo "== Build $@"
$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
- $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+ COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
fi
%_clean:
diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk
index 7bb7219..76ead09 100644
--- a/mk/rte.sharelib.mk
+++ b/mk/rte.sharelib.mk
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
else
LIB_ONE := lib$(RTE_LIBNAME).a
endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
endif
.PHONY:sharelib
@@ -79,6 +81,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
index 0000000..bc40dc8
--- /dev/null
+++ b/scripts/merge_maps.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+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 '1d' | sed '$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
--
2.5.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 1:22 [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library Ferruh Yigit
@ 2015-12-03 1:36 ` Thomas Monjalon
2015-12-03 1:59 ` Ferruh Yigit
2015-12-03 8:18 ` [dpdk-dev] [PATCH v2] " Christian Ehrhardt
2015-12-03 12:49 ` Panu Matilainen
2 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2015-12-03 1:36 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
Hi Ferruh,
Thanks for working on it.
2015-12-03 01:22, Ferruh Yigit:
> +ifeq ($(COMBINED_BUILD),1)
> include $(RTE_SDK)/mk/rte.sharelib.mk
> +endif
[...]
> @if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
> - $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
> + COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
What is it fixing?
The badly named sharelib is for combined build only.
[...]
> +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
The build dir is not always "build/"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 1:36 ` Thomas Monjalon
@ 2015-12-03 1:59 ` Ferruh Yigit
2015-12-03 2:15 ` [dpdk-dev] [PATCH v3] " Ferruh Yigit
0 siblings, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 1:59 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
On Thu, Dec 03, 2015 at 02:36:53AM +0100, Thomas Monjalon wrote:
> Hi Ferruh,
>
> Thanks for working on it.
>
> 2015-12-03 01:22, Ferruh Yigit:
> > +ifeq ($(COMBINED_BUILD),1)
> > include $(RTE_SDK)/mk/rte.sharelib.mk
> > +endif
> [...]
> > @if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
> > - $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
> > + COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
>
> What is it fixing?
> The badly named sharelib is for combined build only.
lib/Makefile and drivers/net/Makefile includes sharelib.mk _always_, this flag is to include sharelib.mk only when we are compiling combined library.
Previously this inclusion was not problem because there was not common variable, now we start using common CPU_LDFLAGS variable and sharedlib.mk shouldn't included when not compiling for combined lib.
>
> [...]
> > +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
>
> The build dir is not always "build/"
>
Thanks, I will fix this and send a new patch, I assume I can rely on "*_version.map" naming convention.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v3] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 1:59 ` Ferruh Yigit
@ 2015-12-03 2:15 ` Ferruh Yigit
2015-12-03 2:22 ` Thomas Monjalon
0 siblings, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 2:15 UTC (permalink / raw)
To: dev
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>
---
drivers/net/Makefile | 3 +++
lib/Makefile | 3 +++
mk/rte.sdkbuild.mk | 2 +-
mk/rte.sharelib.mk | 3 +++
scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
5 files changed, 39 insertions(+), 1 deletion(-)
create mode 100755 scripts/merge_maps.sh
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index cddcd57..d3c865b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
+ifeq ($(COMBINED_BUILD),1)
include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/lib/Makefile b/lib/Makefile
index ef172ea..d0f7fb8 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
endif
+ifeq ($(COMBINED_BUILD),1)
include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
index 38ec7bd..d4e3abf 100644
--- a/mk/rte.sdkbuild.mk
+++ b/mk/rte.sdkbuild.mk
@@ -94,7 +94,7 @@ $(ROOTDIRS-y):
@echo "== Build $@"
$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
- $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+ COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
fi
%_clean:
diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk
index 7bb7219..76ead09 100644
--- a/mk/rte.sharelib.mk
+++ b/mk/rte.sharelib.mk
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
else
LIB_ONE := lib$(RTE_LIBNAME).a
endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
endif
.PHONY:sharelib
@@ -79,6 +81,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
index 0000000..4ace975
--- /dev/null
+++ b/scripts/merge_maps.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -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 '1d' | sed '$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
--
2.5.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 2:15 ` [dpdk-dev] [PATCH v3] " Ferruh Yigit
@ 2015-12-03 2:22 ` Thomas Monjalon
2015-12-03 11:24 ` Ferruh Yigit
0 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2015-12-03 2:22 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
2015-12-03 02:15, Ferruh Yigit:
> +ifeq ($(COMBINED_BUILD),1)
> include $(RTE_SDK)/mk/rte.sharelib.mk
> +endif
I still don't understand what was the issue with this include but it
seems not related to versioning.
Please condider a separate patch with a detailed explanation of the bug.
[...]
> +FILES=$(find $RTE_SDK -name "*_version.map")
No, we can have several build directories in RTE_SDK.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 1:22 [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library Ferruh Yigit
2015-12-03 1:36 ` Thomas Monjalon
@ 2015-12-03 8:18 ` Christian Ehrhardt
2015-12-03 11:18 ` Ferruh Yigit
2015-12-03 12:49 ` Panu Matilainen
2 siblings, 1 reply; 12+ messages in thread
From: Christian Ehrhardt @ 2015-12-03 8:18 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
Hi Ferruh,
some minor bash improvements that could be made in the next revision:
On Thu, Dec 3, 2015 at 2:22 AM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> diff --git a/scripts/merge_maps.sh b/scripts/merge_maps.sh
> new file mode 100755
> index 0000000..bc40dc8
> --- /dev/null
> +++ b/scripts/merge_maps.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +
> +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
> +SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
Guarding $RTE_SDK and $FILES with "" will help avoid some potential
issues due to words splitting.
[...]
> + sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'
As above with $f
[...]
> + if [ "$prev_sym" == "none" ]; then
Should be only one = as == is non standard and could fail in some environments.
Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 8:18 ` [dpdk-dev] [PATCH v2] " Christian Ehrhardt
@ 2015-12-03 11:18 ` Ferruh Yigit
2015-12-03 14:01 ` Ferruh Yigit
0 siblings, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 11:18 UTC (permalink / raw)
To: Christian Ehrhardt; +Cc: dev
On Thu, Dec 03, 2015 at 09:18:49AM +0100, Christian Ehrhardt wrote:
> Hi Ferruh,
> some minor bash improvements that could be made in the next revision:
>
> On Thu, Dec 3, 2015 at 2:22 AM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> > diff --git a/scripts/merge_maps.sh b/scripts/merge_maps.sh
> > new file mode 100755
> > index 0000000..bc40dc8
> > --- /dev/null
> > +++ b/scripts/merge_maps.sh
> > @@ -0,0 +1,29 @@
> > +#!/bin/sh
> > +
> > +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
> > +SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
>
> Guarding $RTE_SDK and $FILES with "" will help avoid some potential
> issues due to words splitting.
>
> [...]
> > + sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'
>
> As above with $f
>
> [...]
> > + if [ "$prev_sym" == "none" ]; then
>
> Should be only one = as == is non standard and could fail in some environments.
>
Thank you Christian, I will update accordingly.
Regards,
ferruh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 2:22 ` Thomas Monjalon
@ 2015-12-03 11:24 ` Ferruh Yigit
0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 11:24 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
On Thu, Dec 03, 2015 at 03:22:39AM +0100, Thomas Monjalon wrote:
> 2015-12-03 02:15, Ferruh Yigit:
> > +ifeq ($(COMBINED_BUILD),1)
> > include $(RTE_SDK)/mk/rte.sharelib.mk
> > +endif
>
> I still don't understand what was the issue with this include but it
> seems not related to versioning.
> Please condider a separate patch with a detailed explanation of the bug.
>
Indeed this is related to the using versioning macros VERSION_SYMBOL, BIND_DEFAULT_SYMBOL
But let me try to fix this in different way
> [...]
> > +FILES=$(find $RTE_SDK -name "*_version.map")
>
> No, we can have several build directories in RTE_SDK.
>
"grep -v" was to remove build output .map files, not searching for _version.map, so it should be OK
but let me narrow search path to lib and drivers folders to be safe
Thanks,
ferruh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 1:22 [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library Ferruh Yigit
2015-12-03 1:36 ` Thomas Monjalon
2015-12-03 8:18 ` [dpdk-dev] [PATCH v2] " Christian Ehrhardt
@ 2015-12-03 12:49 ` Panu Matilainen
2015-12-03 13:51 ` [dpdk-dev] [PATCH v4] " Ferruh Yigit
2 siblings, 1 reply; 12+ messages in thread
From: Panu Matilainen @ 2015-12-03 12:49 UTC (permalink / raw)
To: Ferruh Yigit, dev
On 12/03/2015 03:22 AM, Ferruh Yigit wrote:
> 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>
> ---
> drivers/net/Makefile | 3 +++
> lib/Makefile | 3 +++
> mk/rte.sdkbuild.mk | 2 +-
> mk/rte.sharelib.mk | 3 +++
> scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
> 5 files changed, 39 insertions(+), 1 deletion(-)
> create mode 100755 scripts/merge_maps.sh
>
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index cddcd57..d3c865b 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
> DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
> DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
>
> +ifeq ($(COMBINED_BUILD),1)
> include $(RTE_SDK)/mk/rte.sharelib.mk
> +endif
> +
> include $(RTE_SDK)/mk/rte.subdir.mk
> diff --git a/lib/Makefile b/lib/Makefile
> index ef172ea..d0f7fb8 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
> DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
> endif
>
> +ifeq ($(COMBINED_BUILD),1)
> include $(RTE_SDK)/mk/rte.sharelib.mk
> +endif
> +
> include $(RTE_SDK)/mk/rte.subdir.mk
> diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
> index 38ec7bd..d4e3abf 100644
> --- a/mk/rte.sdkbuild.mk
> +++ b/mk/rte.sdkbuild.mk
> @@ -94,7 +94,7 @@ $(ROOTDIRS-y):
> @echo "== Build $@"
> $(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
> @if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
> - $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
> + COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
> fi
>
> %_clean:
> diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk
> index 7bb7219..76ead09 100644
> --- a/mk/rte.sharelib.mk
> +++ b/mk/rte.sharelib.mk
> @@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
> else
> LIB_ONE := lib$(RTE_LIBNAME).a
> endif
> +COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
> +CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
> endif
>
> .PHONY:sharelib
> @@ -79,6 +81,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
> index 0000000..bc40dc8
> --- /dev/null
> +++ b/scripts/merge_maps.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +
> +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
> +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 '1d' | sed '$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
>
I'd still rather see the combined library replaced with a linker script,
but as long as it is there then +1 for this: with symbol versioning in
place, applications linked to it more likely refuse to start than
randomly crash when ABI changes, internal symbols are hidden etc. And
doesn't require manual updating of two maps since its all scripted.
- Panu -
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH v4] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 12:49 ` Panu Matilainen
@ 2015-12-03 13:51 ` Ferruh Yigit
2015-12-06 14:37 ` Thomas Monjalon
0 siblings, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 13:51 UTC (permalink / raw)
To: dev
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>
---
mk/rte.sharelib.mk | 6 +++++-
scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100755 scripts/merge_maps.sh
diff --git a/mk/rte.sharelib.mk b/mk/rte.sharelib.mk
index 7bb7219..6029b71 100644
--- a/mk/rte.sharelib.mk
+++ b/mk/rte.sharelib.mk
@@ -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
index 0000000..edc88de
--- /dev/null
+++ b/scripts/merge_maps.sh
@@ -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
--
2.5.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 11:18 ` Ferruh Yigit
@ 2015-12-03 14:01 ` Ferruh Yigit
0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2015-12-03 14:01 UTC (permalink / raw)
To: Christian Ehrhardt, dev
On Thu, Dec 03, 2015 at 11:18:27AM +0000, Ferruh Yigit wrote:
> On Thu, Dec 03, 2015 at 09:18:49AM +0100, Christian Ehrhardt wrote:
> > Hi Ferruh,
> > some minor bash improvements that could be made in the next revision:
> >
> > On Thu, Dec 3, 2015 at 2:22 AM, Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> > > diff --git a/scripts/merge_maps.sh b/scripts/merge_maps.sh
> > > new file mode 100755
> > > index 0000000..bc40dc8
> > > --- /dev/null
> > > +++ b/scripts/merge_maps.sh
> > > @@ -0,0 +1,29 @@
> > > +#!/bin/sh
> > > +
> > > +FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
> > > +SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
> >
> > Guarding $RTE_SDK and $FILES with "" will help avoid some potential
> > issues due to words splitting.
I quoted them (not $FILES which grep requires multiple params), but that will not actually help with folder names contains spaces, for that case script is broken.
I fixed script using IFS and a few tricks but made script unnecessarly complex, so I revert back and leaving as it is unless required explicitly.
And I suspect if folder name has spaces this script won't be only thing broken.
Thanks,
ferruh
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v4] mk: fix compile error and ABI versioning for combined shared library
2015-12-03 13:51 ` [dpdk-dev] [PATCH v4] " Ferruh Yigit
@ 2015-12-06 14:37 ` Thomas Monjalon
0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2015-12-06 14:37 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev
2015-12-03 13:51, Ferruh Yigit:
> 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>
Applied, thanks
> +SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
I think SYMBOLS would be better named as VERSIONS.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-12-06 14:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-03 1:22 [dpdk-dev] [PATCH v2] mk: fix compile error and ABI versioning for combined shared library Ferruh Yigit
2015-12-03 1:36 ` Thomas Monjalon
2015-12-03 1:59 ` Ferruh Yigit
2015-12-03 2:15 ` [dpdk-dev] [PATCH v3] " Ferruh Yigit
2015-12-03 2:22 ` Thomas Monjalon
2015-12-03 11:24 ` Ferruh Yigit
2015-12-03 8:18 ` [dpdk-dev] [PATCH v2] " Christian Ehrhardt
2015-12-03 11:18 ` Ferruh Yigit
2015-12-03 14:01 ` Ferruh Yigit
2015-12-03 12:49 ` Panu Matilainen
2015-12-03 13:51 ` [dpdk-dev] [PATCH v4] " Ferruh Yigit
2015-12-06 14:37 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).