From fdb3798d6f870f79d5fa40b2c3425e8285dd4e44 Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Tue, 12 Feb 2019 23:07:05 +0100 Subject: [PATCH] mk: fix build of shared library with libbsd When building DPDK with "make" and options CONFIG_RTE_USE_LIBBSD=y and CONFIG_RTE_BUILD_SHARED_LIB=y libbsd was not linked, resulting in compilation errors: undefined reference to `strlcpy' The link option -lbsd is added in a common place for both Linux apps and libs. It is used in app linkage via EXECENV_LDLIBS, and in lib linkage via the added variable EXECENV_LDLIBS-y. Fixes: 5364de644a4b ("eal: support strlcpy function") Cc: stable@dpdk.org Signed-off-by: Thomas Monjalon --- mk/exec-env/linuxapp/rte.vars.mk | 6 ++++++ mk/rte.app.mk | 3 --- mk/rte.lib.mk | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mk/exec-env/linuxapp/rte.vars.mk b/mk/exec-env/linuxapp/rte.vars.mk index 3129edc8c0..57ee82150b 100644 --- a/mk/exec-env/linuxapp/rte.vars.mk +++ b/mk/exec-env/linuxapp/rte.vars.mk @@ -24,6 +24,8 @@ ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) EXECENV_LDLIBS += -lgcc_s endif +EXECENV_LDLIBS-$(CONFIG_RTE_USE_LIBBSD) += -lbsd + # force applications to link with gcc/icc instead of using ld LINK_USING_CC := 1 @@ -32,4 +34,8 @@ EXECENV_LDFLAGS += -export-dynamic # Add library to the group to resolve symbols EXECENV_LDLIBS += -ldl +# EXECENV_LDLIBS-y applies to lib.so and app linking +# while EXECENV_LDLIBS applies only to app linking. +EXECENV_LDLIBS += $(EXECENV_LDLIBS-y) + export EXECENV_CFLAGS EXECENV_LDFLAGS EXECENV_ASFLAGS EXECENV_LDLIBS diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 8a4f0f4e50..d0ab942d5a 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -309,9 +309,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrt ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP)$(CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lnuma endif -ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP)$(CONFIG_RTE_USE_LIBBSD),yy) -_LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lbsd -endif _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lm _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrt _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMBER) += -lm diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk index c696a21747..4df8849a08 100644 --- a/mk/rte.lib.mk +++ b/mk/rte.lib.mk @@ -35,6 +35,8 @@ PREINSTALL = $(SYMLINK-FILES-y) _INSTALL = $(INSTALL-FILES-y) $(RTE_OUTPUT)/lib/$(LIB) _CLEAN = doclean +LDLIBS += $(EXECENV_LDLIBS-y) + .PHONY: all all: install -- 2.20.1