mk: replace the combined library with a linker script

The physically linked-together combined library has been an increasing
source of problems, as was predicted when library and symbol versioning
was introduced. Replace the complex and fragile construction with a
simple linker script which achieves the same without all the problems,
remove the related kludges from eg mlx drivers.

Since creating the linker script is practically zero cost, remove the
config option and just create it always.

Based on a patch by Sergio Gonzales Monroy, linker script approach
initially suggested by Neil Horman.

Suggested-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Suggested-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
Panu Matilainen 2015-11-24 16:31:17 +02:00 committed by Thomas Monjalon
parent 9792848c65
commit 948fd64bef
17 changed files with 70 additions and 188 deletions

View File

@ -73,11 +73,6 @@ CONFIG_RTE_ARCH_STRICT_ALIGN=n
#
CONFIG_RTE_BUILD_SHARED_LIB=n
#
# Combine to one single library
#
CONFIG_RTE_BUILD_COMBINE_LIBS=n
#
# Use newest code breaking previous ABI
#

View File

@ -73,11 +73,6 @@ CONFIG_RTE_ARCH_STRICT_ALIGN=n
#
CONFIG_RTE_BUILD_SHARED_LIB=n
#
# Combine to one single library
#
CONFIG_RTE_BUILD_COMBINE_LIBS=n
#
# Use newest code breaking previous ABI
#

View File

@ -267,7 +267,7 @@ Checking Compilation
Compilation of patches and changes should be tested using the the ``test-build.sh`` script in the ``scripts``
directory of the DPDK repo::
scripts/test-build.sh x86_64-native-linuxapp-gcc+next+shared+combined
scripts/test-build.sh x86_64-native-linuxapp-gcc+next+shared
The script usage is::
@ -283,10 +283,8 @@ Where:
Examples of configs are::
x86_64-native-linuxapp-gcc
x86_64-native-linuxapp-gcc+next+shared+combined
x86_64-native-linuxapp-gcc+shared+next
x86_64-native-linuxapp-clang+shared+combined
i686-native-linuxapp-gcc+combined
x86_64-native-linuxapp-gcc+next+shared
x86_64-native-linuxapp-clang+shared
The builds can be modifies via the following environmental variables:
@ -302,8 +300,8 @@ These can be set from the command line or in the config files shown above in the
The recommended configurations and options to test compilation prior to submitting patches are::
x86_64-native-linuxapp-gcc+shared+next
x86_64-native-linuxapp-clang+shared+combined
i686-native-linuxapp-gcc+combined
x86_64-native-linuxapp-clang+shared
i686-native-linuxapp-gcc
export DPDK_DEP_ZLIB=y
export DPDK_DEP_PCAP=y

View File

@ -47,11 +47,6 @@ There is also a `section dedicated to this poll mode driver
be enabled manually by setting ``CONFIG_RTE_LIBRTE_MLX4_PMD=y`` and
recompiling DPDK.
.. warning::
``CONFIG_RTE_BUILD_COMBINE_LIBS`` with ``CONFIG_RTE_BUILD_SHARED_LIB``
is not supported and thus the compilation will fail with this configuration.
Implementation details
----------------------

View File

@ -48,11 +48,6 @@ There is also a `section dedicated to this poll mode driver
be enabled manually by setting ``CONFIG_RTE_LIBRTE_MLX5_PMD=y`` and
recompiling DPDK.
.. warning::
``CONFIG_RTE_BUILD_COMBINE_LIBS`` with ``CONFIG_RTE_BUILD_SHARED_LIB``
is not supported and thus the compilation will fail with this configuration.
Implementation details
----------------------

View File

@ -34,5 +34,4 @@ include $(RTE_SDK)/mk/rte.vars.mk
DIRS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += aesni_mb
DIRS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat
include $(RTE_SDK)/mk/rte.sharelib.mk
include $(RTE_SDK)/mk/rte.subdir.mk
include $(RTE_SDK)/mk/rte.subdir.mk

View File

@ -52,5 +52,4 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
include $(RTE_SDK)/mk/rte.sharelib.mk
include $(RTE_SDK)/mk/rte.subdir.mk

View File

@ -31,12 +31,6 @@
include $(RTE_SDK)/mk/rte.vars.mk
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
all:
@echo 'MLX4: Not supported in a combined shared library'
@false
endif
# Library name.
LIB = librte_pmd_mlx4.a

View File

@ -31,12 +31,6 @@
include $(RTE_SDK)/mk/rte.vars.mk
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
all:
@echo 'MLX5: Not supported in a combined shared library'
@false
endif
# Library name.
LIB = librte_pmd_mlx5.a

View File

@ -64,5 +64,4 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
endif
include $(RTE_SDK)/mk/rte.sharelib.mk
include $(RTE_SDK)/mk/rte.subdir.mk

View File

@ -59,10 +59,6 @@ _LDLIBS-y += -L$(RTE_SDK_BIN)/lib
_LDLIBS-y += --whole-archive
_LDLIBS-$(CONFIG_RTE_BUILD_COMBINE_LIBS) += -l$(RTE_LIBNAME)
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
_LDLIBS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += -lrte_distributor
_LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder
@ -88,8 +84,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt
_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lrte_vhost
endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
_LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lnuma
endif
@ -99,9 +93,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lfuse
endif
# The static libraries do not know their dependencies.
# The combined library fails also to store this information.
# So linking with static or combined library requires explicit dependencies.
ifneq ($(CONFIG_RTE_BUILD_COMBINE_LIBS)$(CONFIG_RTE_BUILD_SHARED_LIB),ny)
# So linking with static library requires explicit dependencies.
ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += -lpcap
_LDLIBS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += -lz
_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -libverbs
@ -111,12 +104,10 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += -lxenstore
_LDLIBS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += -lgxio
# QAT PMD has a dependency on libcrypto (from openssl) for calculating HMAC precomputes
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += -lcrypto
endif # CONFIG_RTE_BUILD_COMBINE_LIBS or not CONFIG_RTE_BUILD_SHARED_LIBS
endif # !CONFIG_RTE_BUILD_SHARED_LIBS
_LDLIBS-y += --start-group
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),n)
_LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS) += -lrte_kvargs
_LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF) += -lrte_mbuf
_LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF_OFFLOAD) += -lrte_mbuf_offload
@ -161,8 +152,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += -L$(AESNI_MULTI_BUFFER_LIB_PATH)
endif # ! $(CONFIG_RTE_BUILD_SHARED_LIB)
endif # ! CONFIG_RTE_BUILD_COMBINE_LIBS
_LDLIBS-y += $(EXECENV_LDLIBS)
_LDLIBS-y += --end-group
_LDLIBS-y += --no-whole-archive

58
mk/rte.combinedlib.mk Normal file
View File

@ -0,0 +1,58 @@
# BSD LICENSE
#
# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(RTE_SDK)/mk/rte.vars.mk
default: all
ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
EXT:=.so
else
EXT:=.a
endif
RTE_LIBNAME := dpdk
COMBINEDLIB := lib$(RTE_LIBNAME)$(EXT)
LIBS := $(notdir $(wildcard $(RTE_OUTPUT)/lib/*$(EXT)))
all: FORCE
$(Q)echo "GROUP ( $(LIBS) )" > $(RTE_OUTPUT)/lib/$(COMBINEDLIB)
#
# Clean all generated files
#
.PHONY: clean
clean:
$(Q)rm -f $(RTE_OUTPUT)/lib/$(COMBINEDLIB)
.PHONY: FORCE
FORCE:

View File

@ -138,14 +138,6 @@ endif
$(depfile_newer)),\
$(O_TO_S_DO))
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS)$(EXTLIB_BUILD),yn)
$(if $(or \
$(file_missing),\
$(call cmdline_changed,$(O_TO_C_STR)),\
$(depfile_missing),\
$(depfile_newer)),\
$(O_TO_C_DO))
endif
else
$(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
@ -161,14 +153,6 @@ $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
$(depfile_missing),\
$(depfile_newer)),\
$(O_TO_A_DO))
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS)$(EXTLIB_BUILD),yn)
$(if $(or \
$(file_missing),\
$(call cmdline_changed,$(O_TO_C_STR)),\
$(depfile_missing),\
$(depfile_newer)),\
$(O_TO_C_DO))
endif
endif
#

View File

@ -77,8 +77,8 @@ $(ROOTDIRS-y):
@[ -d $(BUILDDIR)/$@ ] || mkdir -p $(BUILDDIR)/$@
@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; \
@if [ $@ = drivers ]; then \
$(MAKE) -f $(RTE_SDK)/mk/rte.combinedlib.mk; \
fi
%_clean:

View File

@ -1,105 +0,0 @@
# BSD LICENSE
#
# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(RTE_SDK)/mk/internal/rte.build-pre.mk
# VPATH contains at least SRCDIR
VPATH += $(SRCDIR)
ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
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
sharelib: $(LIB_ONE) FORCE
OBJS = $(wildcard $(RTE_OUTPUT)/build/lib/*.o)
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) $(COMBINED_LDFLAGS) \
-shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
endif
O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)")
O_TO_S_CMD = "cmd_$@ = $(O_TO_S_STR)"
O_TO_S_DO = @set -e; \
echo $(O_TO_S_DISP); \
$(O_TO_S)
O_TO_A = $(AR) crus $(RTE_OUTPUT)/lib/$(LIB_ONE) $(OBJS)
O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight
O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)"," LD $(@)")
O_TO_A_CMD = "cmd_$@ = $(O_TO_A_STR)"
O_TO_A_DO = @set -e; \
echo $(O_TO_A_DISP); \
$(O_TO_A)
#
# Archive objects to share library
#
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
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(O_TO_A_DO)
endif
endif
#
# Clean all generated files
#
.PHONY: clean
clean: _postclean
.PHONY: doclean
doclean:
$(Q)rm -rf $(LIB_ONE)
.PHONY: FORCE
FORCE:

View File

@ -66,8 +66,6 @@ endif
RTE_TARGET ?= $(RTE_ARCH)-$(RTE_MACHINE)-$(RTE_EXEC_ENV)-$(RTE_TOOLCHAIN)
RTE_LIBNAME := dpdk
ifeq ($(BUILDING_RTE_SDK),)
# if we are building an external app/lib, include internal/rte.extvars.mk that will
# define RTE_OUTPUT, RTE_SRCDIR, RTE_EXTMK, RTE_SDK_BIN, (etc ...)

View File

@ -55,7 +55,7 @@ print_help () {
-s short test with only first config without examples/doc
config: defconfig name followed by switches delimited with "+" sign
Example: x86_64-native-linuxapp-gcc+next+shared+combined
Example: x86_64-native-linuxapp-gcc+next+shared
Default is to enable most of the options.
The external dependencies are setup with DPDK_DEP_* variables.
END_OF_HELP
@ -101,8 +101,6 @@ config () # <directory> <target> <options>
sed -ri 's,(NEXT_ABI=)y,\1n,' $1/.config
! echo $3 | grep -q shared || \
sed -ri 's,(SHARED_LIB=)n,\1y,' $1/.config
! echo $3 | grep -q combined || \
sed -ri 's,(COMBINE_LIBS=)n,\1y,' $1/.config
echo $2 | grep -q '^i686' || \
sed -ri 's,(NUMA=)n,\1y,' $1/.config
sed -ri 's,(PCI_CONFIG=)n,\1y,' $1/.config
@ -110,7 +108,6 @@ config () # <directory> <target> <options>
sed -ri 's,(BYPASS=)n,\1y,' $1/.config
test "$DPDK_DEP_MOFED" != y || \
echo $2 | grep -q '^clang$' || \
echo $3 | grep -q 'shared.*combined' || \
sed -ri 's,(MLX._PMD=)n,\1y,' $1/.config
test "$DPDK_DEP_SZE" != y || \
echo $2 | grep -q '^i686' || \
@ -122,10 +119,8 @@ config () # <directory> <target> <options>
sed -ri 's,(PCAP=)n,\1y,' $1/.config
test -z "$AESNI_MULTI_BUFFER_LIB_PATH" || \
echo $2 | grep -q '^i686' || \
echo $3 | grep -q 'shared.*combined' || \
sed -ri 's,(PMD_AESNI_MB=)n,\1y,' $1/.config
test "$DPDK_DEP_SSL" != y || \
echo $3 | grep -q 'shared.*combined' || \
sed -ri 's,(PMD_QAT=)n,\1y,' $1/.config
sed -ri 's,(KNI_VHOST.*=)n,\1y,' $1/.config
sed -ri 's,(SCHED_.*=)n,\1y,' $1/.config