Add thunderx (LP: #1691659)
[deb_dpdk.git] / debian / patches / nicvf-0006-mk-fix-lib-filtering-when-linking-app.patch
1 From ab338eb44ebb79840dab1de2742c07070ae3bf0e Mon Sep 17 00:00:00 2001
2 From: Olivier Matz <olivier.matz@6wind.com>
3 Date: Thu, 6 Apr 2017 16:14:55 +0200
4 Subject: [PATCH] mk: fix lib filtering when linking app
5
6 I get the following error when linking the test application:
7   build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o):
8   In function `nicvf_qsize_regbit':
9   drivers/net/thunderx/base/nicvf_hw.c:451: undefined reference to `log2'
10   build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o):
11   In function `nicvf_rss_reta_update':
12   drivers/net/thunderx/base/nicvf_hw.c:804: undefined reference to `log2'
13   build/lib/librte_pmd_thunderx_nicvf.a(nicvf_hw.o):
14   In function `nicvf_rss_reta_query':
15   drivers/net/thunderx/base/nicvf_hw.c:825: undefined reference to `log2'
16
17 While I don't know why it does not happen for a default build, the error
18 can be explained. The link command line is:
19
20    gcc -o test ... *.o ... -Wl,-lm ... -Wl,-lrte_pmd_thunderx_nicvf ...
21
22 rte_pmd_thunderx_nicvf needs the math library, and it should be
23 added after. This is not the case because the test application also
24 adds the math library.
25
26 The makefile already filters the libraries, but it keeps the first
27 occurrence of the lib. Instead, the last one should be kept.
28
29 Fixes: edf4d331dcdb ("mk: eliminate duplicates from libraries list")
30 Cc: stable@dpdk.org
31
32 Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
33 Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
34 ---
35  mk/rte.app.mk | 19 +++++++++++++++----
36  1 file changed, 15 insertions(+), 4 deletions(-)
37
38 Origin: http://dpdk.org/browse/dpdk/commit/?id=ab338eb44ebb79840dab1de2742c07070ae3bf0e
39 Original-Author: Olivier Matz <olivier.matz@6wind.com>
40 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/dpdk/+bug/1691659
41 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
42 Last-Update: 2017-05-18
43
44 --- a/mk/rte.app.mk
45 +++ b/mk/rte.app.mk
46 @@ -168,10 +168,21 @@
47  
48  LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS)
49  
50 -# Eliminate duplicates without sorting
51 -LDLIBS := $(shell echo $(LDLIBS) | \
52 -       awk '{for (i = 1; i <= NF; i++) { \
53 -               if ($$i !~ /^-l.*/ || !seen[$$i]++) print $$i }}')
54 +# all the words except the first one
55 +allbutfirst = $(wordlist 2,$(words $(1)),$(1))
56 +
57 +# Eliminate duplicates without sorting, only keep the last occurrence
58 +filter-libs = \
59 +       $(if $(1),$(strip\
60 +               $(if \
61 +                       $(and \
62 +                               $(filter $(firstword $(1)),$(call allbutfirst,$(1))),\
63 +                               $(filter -l%,$(firstword $(1)))),\
64 +                       ,\
65 +                       $(firstword $(1))) \
66 +               $(call filter-libs,$(call allbutfirst,$(1)))))
67 +
68 +LDLIBS := $(call filter-libs,$(LDLIBS))
69  
70  ifeq ($(RTE_DEVEL_BUILD)$(CONFIG_RTE_BUILD_SHARED_LIB),yy)
71  LDFLAGS += -rpath=$(RTE_SDK_BIN)/lib