From patchwork Thu Apr 6 14:14:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 23296 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id F0108374C; Thu, 6 Apr 2017 16:14:40 +0200 (CEST) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id DB931326C; Thu, 6 Apr 2017 16:14:39 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id A7C8A29879; Thu, 6 Apr 2017 16:14:34 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, stable@dpdk.org Date: Thu, 6 Apr 2017 16:14:55 +0200 Message-Id: <20170406141455.14894-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] mk: fix lib filtering X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" I get the following error when linking the test application: build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o): In function `nicvf_qsize_regbit': drivers/net/thunderx/base/nicvf_hw.c:451: undefined reference to `log2' build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o): In function `nicvf_rss_reta_update': drivers/net/thunderx/base/nicvf_hw.c:804: undefined reference to `log2' build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o): In function `nicvf_rss_reta_query': drivers/net/thunderx/base/nicvf_hw.c:825: undefined reference to `log2' While I don't know why it does not happen for a default build, the error can be explained. The link command line is: gcc -o test ... *.o ... -Wl,-lm ... -Wl,-lrte_pmd_thunderx_nicvf ... rte_pmd_thunderx_nicvf needs the math library, and it should be added after. This is not the case because the test application also adds the math library. The makefile already filters the libraries, but it keeps the first occurrence of the lib. Instead, the last one should be kept. Fixes: edf4d331dcdb ("mk: eliminate duplicates from libraries list") Cc: stable@dpdk.org Signed-off-by: Olivier Matz Acked-by: Thomas Monjalon --- mk/rte.app.mk | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mk/rte.app.mk b/mk/rte.app.mk index fcc3a5795..4c659e971 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -186,10 +186,21 @@ _LDLIBS-y += $(EXECENV_LDLIBS) LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS) -# Eliminate duplicates without sorting -LDLIBS := $(shell echo $(LDLIBS) | \ - awk '{for (i = 1; i <= NF; i++) { \ - if ($$i !~ /^-l.*/ || !seen[$$i]++) print $$i }}') +# all the words except the first one +allbutfirst = $(wordlist 2,$(words $(1)),$(1)) + +# Eliminate duplicates without sorting, only keep the last occurrence +filter-libs = \ + $(if $(1),$(strip\ + $(if \ + $(and \ + $(filter $(firstword $(1)),$(call allbutfirst,$(1))),\ + $(filter -l%,$(firstword $(1)))),\ + ,\ + $(firstword $(1))) \ + $(call filter-libs,$(call allbutfirst,$(1))))) + +LDLIBS := $(call filter-libs,$(LDLIBS)) ifeq ($(RTE_DEVEL_BUILD)$(CONFIG_RTE_BUILD_SHARED_LIB),yy) LDFLAGS += -rpath=$(RTE_SDK_BIN)/lib