From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] mk: fix lib filtering Date: Thu, 06 Apr 2017 16:48:11 +0200 Message-ID: <497164429.X1217vCfaY@xps13> References: <20170406141455.14894-1-olivier.matz@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, stable@dpdk.org To: Olivier Matz Return-path: Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id 1EA182B84 for ; Thu, 6 Apr 2017 16:48:15 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id w11so60568292wrc.3 for ; Thu, 06 Apr 2017 07:48:15 -0700 (PDT) In-Reply-To: <20170406141455.14894-1-olivier.matz@6wind.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2017-04-06 16:14, Olivier Matz: > 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 It is a really nice Makefile recursive function :) > +# 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)) Applied, thanks