From patchwork Wed Jan 9 14:23:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 49543 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 20AC31B4B3; Wed, 9 Jan 2019 15:23:32 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id EEAAB1B48C for ; Wed, 9 Jan 2019 15:23:30 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8DEC6226D3; Wed, 9 Jan 2019 09:23:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 09 Jan 2019 09:23:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=L4g9LdFVXX J2Wg/8C5sQN4xkD4zwFghNw4c9J6ckezc=; b=o3vqJrgTPq84lL0bQm3u6JyIAH gtTyaBGLUrLmdeNPb8vSVWZBoGXp5mW8A7qbqdn1Bpv8POpwaQXtQvRQmRlyAqox 6DvOvE92Wzyo+2HUsFFP88KT6gEMdc/lHsbJTyxGE7np/mdyfFaSCqsBz6fOF4IA gqGdQw/5IePuKmhQA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=L4g9LdFVXXJ2Wg/8C5sQN4xkD4zwFghNw4c9J6ckezc=; b=LWdgZ7bd Sba59OKg5cID0vW6o+1xnP/GvaHXqQouovt91tbz5TLwEWAk2DcjBnZDa1C6TK3c bdw7oJCSkc/Vmwpu1kRkQDLKuog5g1KDwfenh2C87GVnNtwKVgeniCUtrsgRt5nE icz0xWkwi8P+L7E8vqBv3puxww5cKWt1kRazelmEQYNWjJwWCru9fs26N3HMdtLz AvJOEcVkaowgcZFprsFUk4j7mUeKnCKL2eDeyp5S0jskI6BL6cAj0eo3yiC7CjWS NY0k8VpIVRFFJ1NCAI3CsmD5avurQhvrNVtu7kwOh0dKnkPV8cZMxACZMc/yjwjR U6xxeEgLAgOW+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrfedugdeigeculddtuddrgedtkedrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgpdhgih hthhhusghushgvrhgtohhnthgvnhhtrdgtohhmnecukfhppeejjedrudefgedrvddtfedr udekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonh drnhgvthenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 8D272E4394; Wed, 9 Jan 2019 09:23:29 -0500 (EST) From: Thomas Monjalon To: yskoh@mellanox.com, shahafs@mellanox.com Cc: dev@dpdk.org, ferruh.yigit@intel.com, bruce.richardson@intel.com Date: Wed, 9 Jan 2019 15:23:19 +0100 Message-Id: <20190109142319.15148-2-thomas@monjalon.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190109142319.15148-1-thomas@monjalon.net> References: <20190109020524.3633-1-thomas@monjalon.net> <20190109142319.15148-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/2] config: add static linkage of mlx dependency X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The libraries provided by rdma-core may be statically linked if enabling CONFIG_RTE_IBVERBS_LINK_STATIC in the make-based build. If CONFIG_RTE_BUILD_SHARED_LIB is disabled, the applications will embed the mlx PMDs with ibverbs and the mlx libraries. If CONFIG_RTE_BUILD_SHARED_LIB is enabled, the mlx PMDs will embed ibverbs and the mlx libraries. Support with meson may be added later. Signed-off-by: Thomas Monjalon Acked-by: Shahaf Shuler --- v2: no change --- buildtools/options-ibverbs-static.sh | 14 ++++++++++++++ config/common_base | 3 ++- doc/guides/nics/mlx4.rst | 18 ++++++++++++++++++ doc/guides/nics/mlx5.rst | 18 ++++++++++++++++++ drivers/net/mlx4/Makefile | 2 ++ drivers/net/mlx5/Makefile | 2 ++ mk/rte.app.mk | 4 ++++ 7 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 buildtools/options-ibverbs-static.sh diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh new file mode 100755 index 000000000..0f285a343 --- /dev/null +++ b/buildtools/options-ibverbs-static.sh @@ -0,0 +1,14 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# +# Print link options -l for static link of ibverbs. +# +# Static flavour of ibverbs and the providers libs are explicitly picked, +# thanks to the syntax -l:libfoo.a +# Other libs (pthread and nl) are unchanged, i.e. linked dynamically by default. +# +# PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed. + +pkg-config --libs-only-l --static libibverbs | + tr '[:space:]' '\n' | + sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,' diff --git a/config/common_base b/config/common_base index 37f692ce1..f6e5a5396 100644 --- a/config/common_base +++ b/config/common_base @@ -330,8 +330,9 @@ CONFIG_RTE_LIBRTE_MLX5_DEBUG=n # Linking method for mlx4/5 dependency on ibverbs and related libraries # Default linking is dynamic by linker. -# Other option is dynamic by dlopen at run-time. +# Other options are: dynamic by dlopen at run-time, or statically embedded. CONFIG_RTE_IBVERBS_LINK_DLOPEN=n +CONFIG_RTE_IBVERBS_LINK_STATIC=n # # Compile burst-oriented Netronome NFP PMD driver diff --git a/doc/guides/nics/mlx4.rst b/doc/guides/nics/mlx4.rst index 88d467a23..4d4842cde 100644 --- a/doc/guides/nics/mlx4.rst +++ b/doc/guides/nics/mlx4.rst @@ -79,6 +79,11 @@ These options can be modified in the ``.config`` file. This option has no performance impact. +- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**) + + Embed static flavour of the dependencies **libibverbs** and **libmlx4** + in the PMD shared library or the executable static binary. + - ``CONFIG_RTE_LIBRTE_MLX4_DEBUG`` (default **n**) Toggle debugging code and stricter compilation flags. Enabling this option @@ -206,8 +211,21 @@ Current RDMA core package and Linux kernel (recommended) - Minimal Linux kernel version: 4.14. - Minimal RDMA core version: v15 (see `RDMA core installation documentation`_). +- Starting with rdma-core v21, static libraries can be built:: + + cd build + CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja .. + ninja + .. _`RDMA core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md +If rdma-core libraries are built but not installed, DPDK makefile can link them, +thanks to these environment variables: + + - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include`` + - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib`` + - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig`` + .. _Mellanox_OFED_as_a_fallback: Mellanox OFED as a fallback diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 749acd222..5ddca44ee 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -210,6 +210,11 @@ These options can be modified in the ``.config`` file. This option has no performance impact. +- ``CONFIG_RTE_IBVERBS_LINK_STATIC`` (default **n**) + + Embed static flavour of the dependencies **libibverbs** and **libmlx5** + in the PMD shared library or the executable static binary. + - ``CONFIG_RTE_LIBRTE_MLX5_DEBUG`` (default **n**) Toggle debugging code and stricter compilation flags. Enabling this option @@ -577,9 +582,22 @@ RMDA Core with Linux Kernel - rdma-core version 18.0 or above built with 32bit support. - Kernel version 4.14.41 or above. +- Starting with rdma-core v21, static libraries can be built:: + + cd build + CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja .. + ninja + .. _`Linux installation documentation`: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/plain/Documentation/admin-guide/README.rst .. _`RDMA Core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md +If rdma-core libraries are built but not installed, DPDK makefile can link them, +thanks to these environment variables: + + - ``EXTRA_CFLAGS=-I/path/to/rdma-core/build/include`` + - ``EXTRA_LDFLAGS=-L/path/to/rdma-core/build/lib`` + - ``PKG_CONFIG_PATH=/path/to/rdma-core/build/lib/pkgconfig`` + Mellanox OFED ^^^^^^^^^^^^^ diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile index 724a4dcbc..1f1b92748 100644 --- a/drivers/net/mlx4/Makefile +++ b/drivers/net/mlx4/Makefile @@ -43,6 +43,8 @@ CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"' CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' CFLAGS_mlx4_glue.o += -fPIC LDLIBS += -ldl +else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y) +LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh) else LDLIBS += -libverbs -lmlx4 endif diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 47a7f4d68..28460c56f 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -57,6 +57,8 @@ CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"' CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' CFLAGS_mlx5_glue.o += -fPIC LDLIBS += -ldl +else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y) +LDLIBS += $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh) else LDLIBS += -libverbs -lmlx5 endif diff --git a/mk/rte.app.mk b/mk/rte.app.mk index d5b1ec6b7..3ac396236 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -174,6 +174,10 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 -lmnl ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -ldl _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -ldl +else ifeq ($(CONFIG_RTE_IBVERBS_LINK_STATIC),y) +LIBS_IBVERBS_STATIC = $(shell $(RTE_SDK)/buildtools/options-ibverbs-static.sh) +_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += $(LIBS_IBVERBS_STATIC) +_LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += $(LIBS_IBVERBS_STATIC) else _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -libverbs -lmlx4 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -libverbs -lmlx5