diff mbox series

[v5,6/11] linux-gen: dpdk: simplify linking with shared libdpdk

Message ID 1514844007-22122-7-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v5,1/11] helper: link against libpthread and libodp-linux | expand

Commit Message

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


There is no need to pass PMDs when linking with shared DPDK library.
Just pass -ldpdk which will pick up all PMDS dynamically.

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

---
/** Email created from pull request 377 (lumag:misc-fixes)
 ** https://github.com/Linaro/odp/pull/377
 ** Patch: https://github.com/Linaro/odp/pull/377.patch
 ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea
 ** Merge commit sha: 3b7e2ac62accecc65b9f91635a4b6ef04ca77988
 **/
 m4/odp_dpdk.m4                        |  3 +++
 platform/linux-generic/Makefile.am    |  2 +-
 platform/linux-generic/m4/odp_dpdk.m4 | 37 ++++++++++++++++++++++++-----------
 3 files changed, 30 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4
index 05e60cc06..6ea196b7a 100644
--- a/m4/odp_dpdk.m4
+++ b/m4/odp_dpdk.m4
@@ -13,6 +13,9 @@  else
 fi
 done
 AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
+# Hack to circumvent libtool to pass -ldpdk after all PMDS to gcc
+# Otherwise it reorders linking flags and ends up with -ldpdk before all PMDs
+AS_VAR_APPEND([DPDK_PMDS], [" "-Wc,-ldpdk])
 AC_SUBST([DPDK_PMDS])
 ])
 
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 7e40448bd..1136d3692 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -306,7 +306,7 @@  endif
 
 __LIB__libodp_linux_la_LIBADD = $(ATOMIC_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(OPENSSL_LIBS)
-__LIB__libodp_linux_la_LIBADD += $(DPDK_LIBS) $(DPDK_PMDS)
+__LIB__libodp_linux_la_LIBADD += $(DPDK_PMDS) $(DPDK_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(PTHREAD_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(TIMER_LIBS)
 
diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4
index 471bbcd51..2b31c58ab 100644
--- a/platform/linux-generic/m4/odp_dpdk.m4
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -13,16 +13,29 @@  AC_ARG_WITH([dpdk-path],
     [DPDK_PATH="$withval"
      pktio_dpdk_support=yes],[])
 
-AS_IF([test "x$DPDK_PATH" = "xsystem"],
-      [DPDK_CPPFLAGS="-isystem/usr/include/dpdk"
-       DPDK_LDFLAGS=""
-       DPDK_PMD_PATH="`$CC --print-file-name=librte_pmd_null.a`"
-       DPDK_PMD_PATH="`dirname "$DPDK_PMD_PATH"`"
-       AS_IF([test "x$DPDK_PMD_PATH" = "x"],
-	     [AC_MSG_FAILURE([Could not locate system DPDK PMD directory])])],
-      [DPDK_CPPFLAGS="-isystem $DPDK_PATH/include"
-       DPDK_LDFLAGS="-L$DPDK_PATH/lib"
-       DPDK_PMD_PATH="$DPDK_PATH/lib"])
+if test "x$DPDK_PATH" = "xsystem"; then
+    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`"
+    else
+	DPDK_SHARED=yes
+    fi
+    AS_IF([test "x$DPDK_LIB_PATH" = "x"],
+	  [AC_MSG_FAILURE([Could not locate system DPDK library directory])])
+    DPDK_PMD_PATH=`AS_DIRNAME(["$DPDK_PMD_PATH"])`
+else
+    DPDK_CPPFLAGS="-isystem $DPDK_PATH/include"
+    DPDK_LIB_PATH="$DPDK_PATH/lib"
+    DPDK_LDFLAGS="-L$DPDK_LIB_PATH"
+    DPDK_RPATH="-R$DPDK_LIB_PATH"
+    DPDK_PMD_PATH="$DPDK_LIB_PATH"
+    if test -r "$DPDK_LIB_PATH"/libdpdk.so ; then
+	DPDK_SHARED=yes
+    fi
+fi
 
 ##########################################################################
 # Enable zero-copy DPDK pktio
@@ -45,7 +58,9 @@  then
     ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [],
                    [AC_MSG_FAILURE([can't find DPDK])])
 
-    ODP_DPDK_PMDS([$DPDK_PMD_PATH])
+    if test x$DPDK_SHARED != xyes ; then
+	ODP_DPDK_PMDS([$DPDK_PMD_PATH])
+    fi
 
     AC_DEFINE([ODP_PKTIO_DPDK], [1],
 	      [Define to 1 to enable DPDK packet I/O support])