diff mbox series

[v2,1/3] build: another fix for linking with shared libdpdk

Message ID 1516669211-12088-2-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v2,1/3] build: another fix for linking with shared libdpdk | expand

Commit Message

Github ODP bot Jan. 23, 2018, 1 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 416 (lumag:trav-dpdk-shared)
 ** https://github.com/Linaro/odp/pull/416
 ** Patch: https://github.com/Linaro/odp/pull/416.patch
 ** Base sha: b122176ee59494dd957f0f5ff41d4b55a1477e13
 ** Merge commit sha: 91127f4ec35dafb800211b84e2fa8992d7b6d216
 **/
 m4/odp_dpdk.m4                     | 21 +++++++++++++++------
 platform/linux-generic/Makefile.am |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4
index 1887b0431..81ace08a9 100644
--- a/m4/odp_dpdk.m4
+++ b/m4/odp_dpdk.m4
@@ -17,18 +17,29 @@  AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
 
 # _ODP_DPDK_SET_LIBS
 # --------------------
-# Set DPDK_LIBS/DPDK_LIBS_LT depending on DPDK setup
+# Set DPDK_LIBS/DPDK_LIBS_LT/DPDK_LIBS_LIBODP depending on DPDK setup
 AC_DEFUN([_ODP_DPDK_SET_LIBS], [dnl
 AS_IF([test "x$DPDK_SHARED" = "xyes"], [dnl
-    DPDK_LIBS_LT=""
+    # applications don't need to be linked to anything, just rpath
+    DPDK_LIBS_LT="$DPDK_RPATH_LT"
+    # static linking flags will need -ldpdk
+    DPDK_LIBS="-Wl,--no-as-needed,-ldpdk,--as-needed,`echo $DPDK_LIBS | sed -e 's/ /,/g'`"
     DPDK_LIBS="$DPDK_LDFLAGS $DPDK_RPATH $DPDK_LIBS"
+    # link libodp-linux with -ldpdk
+    DPDK_LIBS_LIBODP="$DPDK_LIBS"
 ], [dnl
     ODP_DPDK_PMDS([$DPDK_PMD_PATH])
+    # build long list of libraries for applications, which should not be
+    # rearranged by libtool
     DPDK_LIBS_LT="`echo $DPDK_LIBS | sed -e 's/^/-Wc,/' -e 's/ /,/g'`"
     DPDK_LIBS_LT="$DPDK_LDFLAGS $DPDK_PMDS $DPDK_LIBS_LT $DPDK_LIBS"
+    # static linking flags follow the suite
     DPDK_LIBS="$DPDK_LDFLAGS $DPDK_PMDS $DPDK_LIBS"
+    # link libodp-linux with libtool linking flags
+    DPDK_LIBS_LIBODP="$DPDK_LIBS_LT"
 ])
 AC_SUBST([DPDK_LIBS])
+AC_SUBST([DPDK_LIBS_LIBODP])
 AC_SUBST([DPDK_LIBS_LT])
 ])
 
@@ -99,7 +110,6 @@  AC_DEFUN([ODP_DPDK], [dnl
 AS_IF([test "x$1" = "xsystem"], [dnl
     DPDK_CPPFLAGS="-isystem/usr/include/dpdk"
     DPDK_LDFLAGS=""
-    DPDK_RPATH=""
     DPDK_LIB_PATH="`$CC --print-file-name=libdpdk.so`"
     if test "x$DPDK_LIB_PATH" = "x" ; then
 	DPDK_LIB_PATH="`$CC --print-file-name=libdpdk.a`"
@@ -115,10 +125,9 @@  AS_IF([test "x$1" = "xsystem"], [dnl
     DPDK_LDFLAGS="-L$DPDK_LIB_PATH"
     DPDK_PMD_PATH="$DPDK_LIB_PATH"
     if test -r "$DPDK_LIB_PATH"/libdpdk.so ; then
-	DPDK_RPATH="-R$DPDK_LIB_PATH"
+	DPDK_RPATH="-Wl,-rpath,$DPDK_LIB_PATH"
+	DPDK_RPATH_LT="-R$DPDK_LIB_PATH"
 	DPDK_SHARED=yes
-    else
-	DPDK_RPATH=
     fi
 ])
 _ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [$2], [$3])
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 8585080df..3e38489f6 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -272,7 +272,7 @@  endif
 
 __LIB__libodp_linux_la_LIBADD = $(ATOMIC_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(OPENSSL_LIBS)
-__LIB__libodp_linux_la_LIBADD += $(DPDK_LIBS_LT)
+__LIB__libodp_linux_la_LIBADD += $(DPDK_LIBS_LIBODP)
 __LIB__libodp_linux_la_LIBADD += $(PTHREAD_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(TIMER_LIBS)