[dpdk-dev,v3,5/5] mk: update LDLIBS for app building

Message ID 1428505645-5578-6-git-send-email-sergio.gonzalez.monroy@intel.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

Sergio Gonzalez Monroy April 8, 2015, 3:07 p.m. UTC
  Given the circular dependencies between eal, malloc, mempool and ring
libraries and that eal does not have proper DT_NEEDED entries, we work
around it by forcing linking against mentioned libraries by preceding
them with --no-as-needed flag when building shared libraries.

This patch also does:
 - Set --start-group/--end-group and --whole-archive/--no-whole-archive
   flags only when linking against static DPDK libs.
 - Set --as-needed for all libraries but eal, malloc, mempool and
   ring when linking against shared DPDK libs.
 - Link against EXECENV_LIBS always with --as-needed flag.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 mk/rte.app.mk | 54 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 30 insertions(+), 24 deletions(-)
  

Patch

diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index e8630b6..2d6b2ca 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -59,7 +59,30 @@  LDLIBS += -L$(RTE_SDK_BIN)/lib
 #
 ifeq ($(NO_AUTOLIBS),)
 
-LDLIBS += --whole-archive
+LDLIBS += --no-as-needed
+ifneq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+LDLIBS += --start-group
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
+LDLIBS += -lrte_eal
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
+LDLIBS += -lrte_malloc
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
+LDLIBS += -lrte_mempool
+endif
+
+ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
+LDLIBS += -lrte_ring
+endif
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+LDLIBS += --as-needed
+endif
 
 ifeq ($(CONFIG_RTE_LIBRTE_DISTRIBUTOR),y)
 LDLIBS += -lrte_distributor
@@ -127,7 +150,7 @@  LDLIBS += -lm
 LDLIBS += -lrt
 endif
 
-ifeq ($(CONFIG_RTE_LIBRTE_VHOST), y)
+ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
 LDLIBS += -lrte_vhost
 endif
 
@@ -143,8 +166,6 @@  ifeq ($(CONFIG_RTE_LIBRTE_MLX4_PMD),y)
 LDLIBS += -libverbs
 endif
 
-LDLIBS += --start-group
-
 ifeq ($(CONFIG_RTE_LIBRTE_KVARGS),y)
 LDLIBS += -lrte_kvargs
 endif
@@ -161,22 +182,6 @@  ifeq ($(CONFIG_RTE_LIBRTE_ETHER),y)
 LDLIBS += -lethdev
 endif
 
-ifeq ($(CONFIG_RTE_LIBRTE_MALLOC),y)
-LDLIBS += -lrte_malloc
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_MEMPOOL),y)
-LDLIBS += -lrte_mempool
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_RING),y)
-LDLIBS += -lrte_ring
-endif
-
-ifeq ($(CONFIG_RTE_LIBRTE_EAL),y)
-LDLIBS += -lrte_eal
-endif
-
 ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
 LDLIBS += -lrte_cmdline
 endif
@@ -196,6 +201,7 @@  endif
 
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
 # plugins (link only if static libraries)
+LDLIBS += --whole-archive
 
 ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
@@ -241,14 +247,14 @@  ifeq ($(CONFIG_RTE_LIBRTE_PMD_AF_PACKET),y)
 LDLIBS += -lrte_pmd_af_packet
 endif
 
+LDLIBS += --no-whole-archive
+LDLIBS += --end-group
+LDLIBS += --as-needed
+
 endif # plugins
 
 LDLIBS += $(EXECENV_LDLIBS)
 
-LDLIBS += --end-group
-
-LDLIBS += --no-whole-archive
-
 endif # ifeq ($(NO_AUTOLIBS),)
 
 LDLIBS += $(CPU_LDLIBS)