From patchwork Wed Jan 3 02: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: 123262 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9642683qgn; Tue, 2 Jan 2018 18:10:18 -0800 (PST) X-Google-Smtp-Source: ACJfBotnbhhWUEdiUhGt4Bce3/Kn7a+yLMTTefgy7MnwfzKLpEKjGg/bSEwE2bQcvw3S7aLwXDHp X-Received: by 10.200.4.7 with SMTP id v7mr64659237qtg.129.1514945418036; Tue, 02 Jan 2018 18:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514945418; cv=none; d=google.com; s=arc-20160816; b=MYXE36LQvx7m20mSzwpcNGNhrilZVzclb7AFNnuyS8NpRJjP65YVv6N5JyagU/rA3x P9tAnJ4elQDKm2R2KnqcUk4Ms3RyyRLs87EO7LAbz0PnpBRustWmyxTc2g2W4ZZ5Xowx rakuz2czShetyGq0o5Vmer3Ob23rFEQZ+dEmgsVj/7C9HNJ5BTouFdA4m37P9YKKGClg z7sW0pmbC9P3qUy+fTZgzS8IsWTW8RiSuLy4NOBUXpiIixTaQIlxsJHzbmcucxdbp2Bf H7oJIHK2oJBcuKw6ZuU6Z6fOSS+aEzfNth82Xf8POe/E/WaLLEkJernmJDKj7nSCGVNh WLew== 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=xlPUBlMaZwwQLkhdZdq0eoG1a5CM4kQFdpc3IDA/pHc=; b=BISiI68F1wy4VENH8J7WZLJqLZi+loeArUm0df36q95BhMtRPA5xUOUHVU4noq6oti cl26Ss7vpQ0vgxrIHCNs1looXmxs2v+q/B+vbieE1+FXGxE9EjCE8b0w37PiLCXfQkTE OvYzP/nt7ltJs6GLUWP7rblcvGcTJwezhkk8Z1lRBXT4rjjbDxCm5PL1Vo0gB7iCGXRG QExoDVUmumNU9EZtlgszIoIRGEmGFoez0kthvCMK9iq7bCZt9cWRMjmSw+BGK5P3uQGj P//Z+UAgKJtgSGgyqhL7KfPx2YxNxzXtJ6SBB0gFrpZw5dM3rQWoxreYLA0yl2MHd9YN iJkA== 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 o49si1769qtf.222.2018.01.02.18.10.17; Tue, 02 Jan 2018 18:10:18 -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 BD99060AEF; Wed, 3 Jan 2018 02:10:17 +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 A7D05614FD; Wed, 3 Jan 2018 02:01:14 +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 4BC7F6084F; Wed, 3 Jan 2018 02:00:29 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id AC59760846 for ; Wed, 3 Jan 2018 02:00:16 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 687E618027CE for ; Wed, 3 Jan 2018 05:00:15 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BubK5X5DVo-0FX0kTY5; Wed, 03 Jan 2018 05:00:15 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id GWEi9ANDSh-0ET8kQ61; Wed, 03 Jan 2018 05:00:14 +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 05:00:01 +0300 Message-Id: <1514944809-29308-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514944809-29308-1-git-send-email-odpbot@yandex.ru> References: <1514944809-29308-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 377 Subject: [lng-odp] [PATCH v8 7/15] 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: c5df42a14c866959ebcb501d64de76a99b6b00d7 **/ 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)