Skip to contentSkip to conversation

mk: fix build with shared library

PATCH Superseded Stephen Hemminger 1 participant 3 messages Jul 24, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mk: fix build with shared library

If RTE_BUILD_SHARED_LIB is enabled, then there a couple of places in the mk scripts where constructors are not called but need to be.

Stephen Hemminger (2):
mk: fix missing pci bus with shared library build
mk: fix missing mempool driver registration

 mk/rte.app.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 mk: fix missing pci bus with shared library build

If DPDK is built as a shared library, then any application linked with rte.app.mk will not find any buses (including PCI devices).

This is because the linker will not call the initializers of the bus libraries since they are not directly called by application or EAL.

Bugzilla ID: 333

Fixes c752998b5e2e ("pci: introduce library and driver")
---
 mk/rte.app.mk | 7 +++++++
 1 file changed, 7 insertions(+)
mk/rte.app.mk +7 -0
index a277c808ed8e..3b3156bfcf09 100644
@@ -123,6 +123,10 @@ ifneq (,$(findstring y,$(MVEP-y)))
 _LDLIBS-y += -lrte_common_mvep -L$(LIBMUSDK_PATH)/lib -lmusdk
 endif
 
+# Bus devices use constructors to register and therefore
+# need to be always linked in (--whole-archive already enabled)
+_LDLIBS-y += --no-as-needed
+
 ifeq ($(CONFIG_RTE_LIBRTE_DPAA_BUS),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_COMMON_DPAAX)   += -lrte_common_dpaax
 endif
@@ -137,6 +141,9 @@ ifeq ($(CONFIG_RTE_EAL_VFIO),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS)      += -lrte_bus_fslmc
 endif
 
+# drivers are as-needed
+_LDLIBS-y += --as-needed
+
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
 # plugins (link only if static libraries)
 
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 mk: fix missing mempool driver registration

In reply to Stephen Hemminger

Since mempool driver is now registered during constructor, the mempool driver must always be linked in during shared library build. Otherwise, application will fail because of missing default mbuf pool operations.

Fixes c6b3570f9e14 ("mk: link app with ring mempool by default")
Cc stable.dpdk.org
---
 mk/rte.app.mk | 2 ++
 1 file changed, 2 insertions(+)
mk/rte.app.mk +2 -0
index 3b3156bfcf09..3e4580a2594c 100644
@@ -87,7 +87,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RAWDEV)         += -lrte_rawdev
 _LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER)          += -lrte_timer
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMPOOL)        += -lrte_mempool
 _LDLIBS-$(CONFIG_RTE_LIBRTE_STACK)          += -lrte_stack
+_LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING)   += --no-as-needed
 _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING)   += -lrte_mempool_ring
+_LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING)   += --as-needed
 _LDLIBS-$(CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL) += -lrte_mempool_octeontx2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PCI)            += -lrte_pci
Signature · 1 line
2.20.1