[dpdk-stable] [PATCH] mk: fix lib filtering
Thomas Monjalon
thomas.monjalon at 6wind.com
Thu Apr 6 16:48:11 CEST 2017
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 at dpdk.org
> Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
Acked-by: Thomas Monjalon <thomas.monjalon at 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
More information about the stable
mailing list