From patchwork Wed Jan 3 01:00:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123244 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9597332qgn; Tue, 2 Jan 2018 17:06:58 -0800 (PST) X-Google-Smtp-Source: ACJfBotovM31UHPKKkHBFS2bDIhW8pjyYVQguw85H1UkZRLbGOfPJYCV9CfEKLOhD2s/INaWgGxm X-Received: by 10.55.115.194 with SMTP id o185mr16245762qkc.171.1514941617982; Tue, 02 Jan 2018 17:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514941617; cv=none; d=google.com; s=arc-20160816; b=dXxCUSH5AXNxaRh7JHtVlEpOufD/B9QndJYdjrgPZ/GmeIadBemF60JacctFsHJFyD YiTiOEwyHXOkLazT26GrSGLope5wPdTP61QU/rYCasdDoSjLTJQPaBddxFPH6Z8t9CBX wLiMxOwlaSO3aG4hxB0INPRQ3MZicjRhQNl6NOmWNJ/ZFkaxbxNuLDfGIG1k01wxt7UQ +aiT1NtRlAkdyvbchBYQZMOZV5r6lAsxERFoxTGiDf0FnMBE/Xgb3ZYGFXCzkXnXyK0R sQkwX+O+OBWHhNODjcJ+t5oWr0cj14MLa0KQYhaxF/h+DGpaERG6am2p0CPrOVRzk+e2 Dz0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=R2beRHiZeggrfAdTqLpeU4CGwrPdEpFh4voaIZQh3E0=; b=ab1752yjV2mhXvNfYvCuLp0HH0Zen8y165W7nWB2YCSjyGGGTgQF2yX5vYHLLLC2eI Kp8p5Gfwu9Dz/30gBHPEG/OEUm80z+aA2Qx/G4REOEQCn7XfT+0GxvipEUVF0GJqJEQJ 1sCWRsQoFYreIptsdckauuYiaUoRpRRfu1SOs+EBKkCknrEUSr3v4Sqfcz6Qh+PCeO1F vR1Qso0yPEsQYuBa9DGByUIH9GfCz5hzXLqFB2rXq8wLl7N4N7MqLoPrTe24kdZyDKRl 7aLzzNwG8ihoteTExk43qdnKw77aBPSlcOFIjUINgYdeffnsNkL4za8HazFFDf7DHz/n LlXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id l185si4177510qkf.153.2018.01.02.17.06.57; Tue, 02 Jan 2018 17:06:57 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9C8AA6152C; Wed, 3 Jan 2018 01:06:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 20C3C60846; Wed, 3 Jan 2018 01:04:43 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id AE16B608E2; Wed, 3 Jan 2018 01:04:33 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 1C931608E2 for ; Wed, 3 Jan 2018 01:01:43 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward104o.mail.yandex.net (Yandex) with ESMTP id C31E4701EE3 for ; Wed, 3 Jan 2018 04:01:41 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dvGFGiKaEx-1fZufWTl; Wed, 03 Jan 2018 04:01:41 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id RCuoSjuFoy-1ItqhU17; Wed, 03 Jan 2018 04:01:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 3 Jan 2018 04:00:01 +0300 Message-Id: <1514941208-27772-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514941208-27772-1-git-send-email-odpbot@yandex.ru> References: <1514941208-27772-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 377 Subject: [lng-odp] [PATCH v7 7/14] linux-gen: dpdk: simplify linking with shared libdpdk X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov There is no need to pass PMDs when linking with shared DPDK library. Just pass -ldpdk which will pick up all PMDS dynamically. When linking with static DPKD library it is required to pass additional libraries after whole PMD string to fix linking when Libtool will reorder flags. So provide just two variables DPDK_LIBS and DPDK_LIBS_LT. Former should be passed directly to gcc, while later should be passed to libtool. Signed-off-by: Dmitry Eremin-Solenikov --- /** 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: d0774cfbe328bb3678434b9903bf0f8abb25611b **/ example/Makefile.inc | 2 +- m4/odp_dpdk.m4 | 83 ++++++++++++++++++++++++------- platform/linux-generic/Makefile.am | 2 +- platform/linux-generic/libodp-linux.pc.in | 2 +- platform/linux-generic/m4/odp_dpdk.m4 | 24 +-------- platform/linux-generic/test/Makefile.inc | 2 +- test/Makefile.inc | 2 +- test/validation/api/Makefile.inc | 1 - 8 files changed, 73 insertions(+), 45 deletions(-) diff --git a/example/Makefile.inc b/example/Makefile.inc index 4cf5cfacc..829977ce8 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -1,7 +1,7 @@ TESTS_ENVIRONMENT = EXEEXT=${EXEEXT} LIB = $(top_builddir)/lib -LDADD = $(LIB)/libodp-linux.la $(LIB)/libodphelper.la $(DPDK_PMDS) +LDADD = $(LIB)/libodp-linux.la $(LIB)/libodphelper.la $(DPDK_LIBS_LT) AM_CFLAGS = \ -I$(srcdir) \ -I$(top_srcdir)/example \ diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4 index 05e60cc06..1887b0431 100644 --- a/m4/odp_dpdk.m4 +++ b/m4/odp_dpdk.m4 @@ -1,22 +1,38 @@ # ODP_DPDK_PMDS(DPDK_DRIVER_PATH) # ------------------------------- -# Build a list of DPDK PMD drivers in DPDK_PMDS variable +# Build a list of DPDK PMD drivers in DPDK_PMDS variable. +# Updated DPDK_LIBS to include dependencies. AC_DEFUN([ODP_DPDK_PMDS], [dnl -AS_VAR_SET([DPDK_PMDS], [-Wl,--whole-archive,]) +AS_VAR_SET([DPDK_PMDS], ["-Wl,--whole-archive,"]) for filename in "$1"/librte_pmd_*.a; do cur_driver=`basename "$filename" .a | sed -e 's/^lib//'` -# rte_pmd_nfp has external dependencies which break linking -if test "$cur_driver" = "rte_pmd_nfp"; then - echo "skip linking rte_pmd_nfp" -else - AS_VAR_APPEND([DPDK_PMDS], [-l$cur_driver,]) -fi +AS_VAR_APPEND([DPDK_PMDS], [-l$cur_driver,]) +AS_CASE([$cur_driver], + [rte_pmd_nfp], [AS_VAR_APPEND([DPDK_LIBS], [" -lm"])], + [rte_pmd_pcap], [AS_VAR_APPEND([DPDK_LIBS], [" -lpcap"])], + [rte_pmd_openssl], [AS_VAR_APPEND([DPDK_LIBS], [" -lcrypto"])]) done AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive]) -AC_SUBST([DPDK_PMDS]) ]) -# _ODP_DPDK_CHECK_LIB(LDFLAGS, [LIBS], [EXTRA_LIBS]) +# _ODP_DPDK_SET_LIBS +# -------------------- +# Set DPDK_LIBS/DPDK_LIBS_LT depending on DPDK setup +AC_DEFUN([_ODP_DPDK_SET_LIBS], [dnl +AS_IF([test "x$DPDK_SHARED" = "xyes"], [dnl + DPDK_LIBS_LT="" + DPDK_LIBS="$DPDK_LDFLAGS $DPDK_RPATH $DPDK_LIBS" +], [dnl + ODP_DPDK_PMDS([$DPDK_PMD_PATH]) + 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" + DPDK_LIBS="$DPDK_LDFLAGS $DPDK_PMDS $DPDK_LIBS" +]) +AC_SUBST([DPDK_LIBS]) +AC_SUBST([DPDK_LIBS_LT]) +]) + +# _ODP_DPDK_CHECK_LIB(LDFLAGS, [LIBS]) # ---------------------------------- # Check if one can use -ldpdk with provided set of libs AC_DEFUN([_ODP_DPDK_CHECK_LIB], [dnl @@ -31,7 +47,7 @@ LIBS="$LIBS -ldpdk $2" AC_MSG_CHECKING([for rte_eal_init in -ldpdk $2]) AC_LINK_IFELSE([AC_LANG_CALL([], [rte_eal_init])], [AC_MSG_RESULT([yes]) - DPDK_LIBS="$1 -ldpdk $3 $2"], + DPDK_LIBS="-ldpdk $2"], [AC_MSG_RESULT([no])]) ########################################################################## @@ -41,10 +57,10 @@ LDFLAGS=$OLD_LDFLAGS LIBS=$OLD_LIBS ]) -# ODP_DPDK_CHECK(CPPFLAGS, LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) -# ----------------------------------------------------------------------- +# _ODP_DPDK_CHECK(CPPFLAGS, LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) +# ------------------------------------------------------------------------ # Check for DPDK availability -AC_DEFUN([ODP_DPDK_CHECK], [dnl +AC_DEFUN([_ODP_DPDK_CHECK], [dnl ########################################################################## # Save and set temporary compilation flags ########################################################################## @@ -59,13 +75,14 @@ AC_CHECK_HEADERS([rte_config.h], [], DPDK_LIBS="" _ODP_DPDK_CHECK_LIB([$2]) AS_IF([test "x$DPDK_LIBS" = "x"], - [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread], [-lm])]) + [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread])]) AS_IF([test "x$DPDK_LIBS" = "x"], - [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread -lnuma], [-lm])]) + [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread -lnuma])]) AS_IF([test "x$DPDK_LIBS" = "x"], [dpdk_check_ok=no]) AS_IF([test "x$dpdk_check_ok" != "xno"], - [AC_SUBST([DPDK_LIBS]) + [_ODP_DPDK_SET_LIBS + AC_SUBST([DPDK_CPPFLAGS]) m4_default([$3], [:])], [m4_default([$4], [:])]) @@ -74,3 +91,35 @@ AS_IF([test "x$dpdk_check_ok" != "xno"], ########################################################################## CPPFLAGS=$OLD_CPPFLAGS ]) + +# ODP_DPDK(DPDK_PATH, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# ----------------------------------------------------------------------- +# Check for DPDK availability +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`" + 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"])` +], [dnl + DPDK_CPPFLAGS="-isystem $1/include" + DPDK_LIB_PATH="$1/lib" + 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_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 7e40448bd..92ce2cce6 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_LIBS_LT) __LIB__libodp_linux_la_LIBADD += $(PTHREAD_LIBS) __LIB__libodp_linux_la_LIBADD += $(TIMER_LIBS) diff --git a/platform/linux-generic/libodp-linux.pc.in b/platform/linux-generic/libodp-linux.pc.in index 962a4f78f..5125f83ad 100644 --- a/platform/linux-generic/libodp-linux.pc.in +++ b/platform/linux-generic/libodp-linux.pc.in @@ -7,5 +7,5 @@ Name: libodp-linux Description: The ODP packet processing engine Version: @PKGCONFIG_VERSION@ Libs: -L${libdir} -lodp-linux -Libs.private: @OPENSSL_STATIC_LIBS@ @DPDK_PMDS@ @DPDK_LIBS@ @PCAP_LIBS@ @PTHREAD_LIBS@ @TIMER_LIBS@ -lpthread @ATOMIC_LIBS@ +Libs.private: @OPENSSL_STATIC_LIBS@ @DPDK_LIBS@ @PCAP_LIBS@ @PTHREAD_LIBS@ @TIMER_LIBS@ -lpthread @ATOMIC_LIBS@ Cflags: -I${includedir} diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4 index 471bbcd51..b2193a168 100644 --- a/platform/linux-generic/m4/odp_dpdk.m4 +++ b/platform/linux-generic/m4/odp_dpdk.m4 @@ -13,17 +13,6 @@ 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"]) - ########################################################################## # Enable zero-copy DPDK pktio ########################################################################## @@ -42,22 +31,13 @@ AC_ARG_ENABLE([dpdk-zero-copy], ########################################################################## if test x$pktio_dpdk_support = xyes then - ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [], - [AC_MSG_FAILURE([can't find DPDK])]) - - ODP_DPDK_PMDS([$DPDK_PMD_PATH]) + ODP_DPDK([$DPDK_PATH], [], + [AC_MSG_FAILURE([can't find DPDK])]) AC_DEFINE([ODP_PKTIO_DPDK], [1], [Define to 1 to enable DPDK packet I/O support]) AC_DEFINE_UNQUOTED([ODP_DPDK_ZERO_COPY], [$zero_copy], [Define to 1 to enable DPDK zero copy support]) - - if test -r "$DPDK_PMD_PATH/librte_pmd_pcap.a" && - ! test -r "$DPDK_PMD_PATH/librte_pmd_pcap.so" ; then - DPDK_LIBS="$DPDK_LIBS -lpcap" - fi - AC_SUBST([DPDK_CPPFLAGS]) - AC_SUBST([DPDK_LIBS]) else pktio_dpdk_support=no fi diff --git a/platform/linux-generic/test/Makefile.inc b/platform/linux-generic/test/Makefile.inc index dd21917eb..419a63d1c 100644 --- a/platform/linux-generic/test/Makefile.inc +++ b/platform/linux-generic/test/Makefile.inc @@ -8,7 +8,7 @@ AM_CFLAGS = $(CUNIT_CFLAGS) LIBCUNIT_COMMON = $(top_builddir)/test/common/libcunit_common.la LIB = $(top_builddir)/lib -LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_PMDS) +LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_LIBS_LT) INCCUNIT_COMMON = -I$(top_srcdir)/test/common INCODP = \ diff --git a/test/Makefile.inc b/test/Makefile.inc index d7e435038..857de4512 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -3,7 +3,7 @@ LIB = $(top_builddir)/lib #in the following line, the libs using the symbols should come before #the libs containing them! The includer is given a chance to add things #before libodp by setting PRE_LDADD before the inclusion. -LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_PMDS) +LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_LIBS_LT) INCFLAGS = \ -I$(top_builddir)/platform/@with_platform@/include \ diff --git a/test/validation/api/Makefile.inc b/test/validation/api/Makefile.inc index 4af010002..6e66301be 100644 --- a/test/validation/api/Makefile.inc +++ b/test/validation/api/Makefile.inc @@ -3,7 +3,6 @@ include $(top_srcdir)/test/Makefile.inc COMMON_DIR = $(top_builddir)/test/common AM_CFLAGS += -I$(top_srcdir)/test/common -AM_LDFLAGS += $(DPDK_PMDS) AM_CFLAGS += $(CUNIT_CFLAGS)