All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mk: fix lib filtering
@ 2017-04-06 14:14 Olivier Matz
  2017-04-06 14:48 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Matz @ 2017-04-06 14:14 UTC (permalink / raw)
  To: dev; +Cc: thomas.monjalon, stable

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 <olivier.matz@6wind.com>
---
 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
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mk: fix lib filtering
  2017-04-06 14:14 [PATCH] mk: fix lib filtering Olivier Matz
@ 2017-04-06 14:48 ` Thomas Monjalon
  2017-04-06 16:20   ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2017-04-06 14:48 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, stable

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 <olivier.matz@6wind.com>

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mk: fix lib filtering
  2017-04-06 14:48 ` Thomas Monjalon
@ 2017-04-06 16:20   ` Bruce Richardson
  2017-04-06 16:25     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2017-04-06 16:20 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Olivier Matz, dev, stable

On Thu, Apr 06, 2017 at 04:48:11PM +0200, Thomas Monjalon wrote:
> 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 <olivier.matz@6wind.com>
> 
> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
> 
> It is a really nice Makefile recursive function :)
> 

"nice Makefile recursive function"

I recognise those words individually, but having them together just
doesn't make any sense :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mk: fix lib filtering
  2017-04-06 16:20   ` Bruce Richardson
@ 2017-04-06 16:25     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-04-06 16:25 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: Olivier Matz, dev

2017-04-06 17:20, Bruce Richardson:
> On Thu, Apr 06, 2017 at 04:48:11PM +0200, Thomas Monjalon wrote:
> > It is a really nice Makefile recursive function :)
> 
> "nice Makefile recursive function"
> 
> I recognise those words individually, but having them together just
> doesn't make any sense :-)

Thanks for your attention :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-06 16:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 14:14 [PATCH] mk: fix lib filtering Olivier Matz
2017-04-06 14:48 ` Thomas Monjalon
2017-04-06 16:20   ` Bruce Richardson
2017-04-06 16:25     ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.