From: Olivier Matz Date: Fri, 27 Jan 2017 14:23:17 +0000 (+0100) Subject: efd: fix build by removing dependency to libmath X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cb8fac62beb741e4fdacb41be2b242e964b75f73;p=dpdk.git efd: fix build by removing dependency to libmath When we compile the dpdk with: CONFIG_RTE_LIBRTE_EFD=y CONFIG_RTE_LIBRTE_NFP_PMD=n CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=n CONFIG_RTE_LIBRTE_SCHED=n CONFIG_RTE_LIBRTE_METER=n The linker gives the following error: lib/librte_efd.a(rte_efd.o): In function `rte_efd_create': lib/librte_efd/rte_efd.c:560: undefined reference to `log2' collect2: error: ld returned 1 exit status This is because the '-lm' is missing in mk/rte.app.mk. An alternative, which is proposed by this patch, is to use the compiler builtin rte_bsf32() to process log2 instead of the libmath log2() that requires to include math.h and link with -lm. Fixes: 56b6ef874f80 ("efd: new Elastic Flow Distributor library") Signed-off-by: Olivier Matz Acked-by: Pablo de Lara --- diff --git a/lib/librte_efd/Makefile b/lib/librte_efd/Makefile index 8848c58623..a442c6260c 100644 --- a/lib/librte_efd/Makefile +++ b/lib/librte_efd/Makefile @@ -34,8 +34,6 @@ include $(RTE_SDK)/mk/rte.vars.mk # library name LIB = librte_efd.a -LDLIBS += -lm - CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c index 68e6dab02d..f601d62e32 100644 --- a/lib/librte_efd/rte_efd.c +++ b/lib/librte_efd/rte_efd.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -557,7 +556,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, num_chunks = rte_align32pow2((max_num_rules / EFD_TARGET_CHUNK_NUM_RULES) + 1); - num_chunks_shift = log2(num_chunks); + num_chunks_shift = rte_bsf32(num_chunks); rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);