From patchwork Thu Jan 16 07:16:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 64751 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AFDC9A04F9; Thu, 16 Jan 2020 08:17:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6EB1E1C0D5; Thu, 16 Jan 2020 08:17:10 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 24A841C0AA for ; Thu, 16 Jan 2020 08:17:09 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C169F22129; Thu, 16 Jan 2020 02:17:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 16 Jan 2020 02:17:08 -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=XsjFYxxCJN b9hB5pP/BjHWkJNsoY/FdwSsRfNc9wadI=; b=mFd6Ss87h3GGw3eYby+V58N+k+ HVNcpjIKPbnqa/RfiOT5a3A8bxLKTNvAJKFKmVgLw3JcDalN/ejT6F3z4TbIOHCI uIxgtCI/HSl19uJA4s9TdXL7Zl9Zwo3aDpprVS8wIfo8i39yKpmcb8yBdP1z7GAW N/tYkMmCSUioyhjPk= 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=XsjFYxxCJNb9hB5pP/BjHWkJNsoY/FdwSsRfNc9wadI=; b=Qdw9Dz5M fAaTgTxGbykdCh3DfWlFOI+w3mDnILnSE4sc2zHYcO9bL3z4P9RIEBUmTJI4zS8o HihIsrNItwKcXyVw+YdURXvhwtRB7cfnMUAptlHy+G7gdp/mQg1QycQo5Lc1hX9f /qmpvT1FQUIwDdkvnUI5nDJgOqdskHR+tDSm87WyNCgTTmd571s/EdDUUIqy0L0L 66jmtog5Ym1GHOxG9dbjQQb5r1WWqM44GIgsxhsbrEzSHPUlsFgkAYG5/GRqJK8T tixC+8N9ECY4QoA7PAF2lJdDHu4PiFEbI2OGjqk7oHuILCY9KzfcDOsTxxZMva4P hNyaS0k1nTKl6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtdeggddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukf hppeejjedrudefgedrvddtfedrudekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhh ohhmrghssehmohhnjhgrlhhonhdrnhgvthenucevlhhushhtvghrufhiiigvpedt 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 1209C30607B0; Thu, 16 Jan 2020 02:17:07 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Date: Thu, 16 Jan 2020 08:16:54 +0100 Message-Id: <20200116071656.1663967-2-thomas@monjalon.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200116071656.1663967-1-thomas@monjalon.net> References: <20200116071656.1663967-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script 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 shell script options-ibverbs-static.sh was used with make in forcing static linkage of ibverbs dependency. It is now renamed pkg-config-static.sh and it is made generic, i.e. it can work with any .pc library file. The idea is to distinguish its own libraries and the dependencies by looking at the -L directory. Only the found static libraries are forced to static. The -L path is added in this new version in order to fill the .pc file generated in DPDK. Signed-off-by: Thomas Monjalon --- buildtools/options-ibverbs-static.sh | 14 ------------- buildtools/pkg-config-static.sh | 31 ++++++++++++++++++++++++++++ drivers/net/mlx4/Makefile | 2 +- drivers/net/mlx5/Makefile | 2 +- mk/rte.app.mk | 3 ++- 5 files changed, 35 insertions(+), 17 deletions(-) delete mode 100755 buildtools/options-ibverbs-static.sh create mode 100755 buildtools/pkg-config-static.sh diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh deleted file mode 100755 index 0f285a343b..0000000000 --- a/buildtools/options-ibverbs-static.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /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/buildtools/pkg-config-static.sh b/buildtools/pkg-config-static.sh new file mode 100755 index 0000000000..77401c2f45 --- /dev/null +++ b/buildtools/pkg-config-static.sh @@ -0,0 +1,31 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2020 Mellanox Technologies, Ltd +# +# Convert pkg-config link options for static linkage. +# +# Static flavour of provided libs are explicitly picked, +# thanks to the syntax -l:libfoo.a +# Other libs (dependencies) are unchanged, i.e. linked dynamically by default. +# +# Syntax: pkg-config-static.sh +# +# PKG_CONFIG_PATH may be required to be set if the .pc file is not installed. + +ldflags=$(pkg-config --libs --static $1 | tr '[:space:]' '\n') +dir=$(echo "$ldflags" | sed -rn 's,^-L(.*),\1,p' | head -n1) +IFS=' +' +for arg in $ldflags ; do + prefix=$(echo $arg | sed -rn 's/^(-Wl,).*/\1/p') + option=$(echo $arg | sed -rn "s/^$prefix-(.*=|.*,|.).*/\1/p") + [ "$option" = 'l' -o "$option" = 'L' ] || continue + value=$(echo $arg | sed "s/^$prefix-$option//") + staticlib="lib$value.a" + printf -- -$option + if [ -f $dir/$staticlib ] ; then + echo :$staticlib + else + echo $value + fi +done | tr '\n' ' ' diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile index 329569dc10..4ef14b3a07 100644 --- a/drivers/net/mlx4/Makefile +++ b/drivers/net/mlx4/Makefile @@ -45,7 +45,7 @@ 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) +LDLIBS += $(shell $(RTE_SDK)/buildtools/pkg-config-static.sh libibverbs) else LDLIBS += -libverbs -lmlx4 endif diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index c5cf4397ac..eb11123867 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -60,7 +60,7 @@ 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) +LDLIBS += $(shell $(RTE_SDK)/buildtools/pkg-config-static.sh libibverbs) else LDLIBS += -libverbs -lmlx5 endif diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 05ea034b99..1062fcc732 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -195,7 +195,8 @@ 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) +LIBS_IBVERBS_STATIC = $(shell $(RTE_SDK)/buildtools/pkg-config-static.sh \ + libibverbs | sed 's/-Wl,//') _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += $(LIBS_IBVERBS_STATIC) _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += $(LIBS_IBVERBS_STATIC) else From patchwork Thu Jan 16 07:16:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 64752 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AD8CDA04F9; Thu, 16 Jan 2020 08:17:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 560B71C066; Thu, 16 Jan 2020 08:17:15 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 59E0E1C020 for ; Thu, 16 Jan 2020 08:17:13 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 03463220C9; Thu, 16 Jan 2020 02:17:12 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 16 Jan 2020 02:17:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=zhuDxfyIXD prTZjE+NROPLRsEuPXjg6R0IfN0YZoofA=; b=r4REsDVxtucYEcYhbPuOM9MsB7 Toc8+fe8ihur3LWo4Hm6orj0ntii6Ym9hVs89+LKpethViTuaCsM0gkROYAZd2v/ OTKUlOolE/6FPYdd3raTUhH68RwaL5A8cUBX35Jp2uFjwaaaDIHZDTJDcIAOi45a 6Nu7N7BE76UX8mcP0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=zhuDxfyIXDprTZjE+NROPLRsEuPXjg6R0IfN0YZoofA=; b=DMcE+7Bc ZREoQ9cPiURDs4jJmXB8y7F/GI0b7Gs9Qw/PHGRQwwYwUIjhM2Pd1ulQmR9y/du1 h1N5Wbmfa9O9MBlSQZPFk6edKYWTvrRFrcn3yhqcnHp2DldQ7ybZouAtBaeLChjU WKbSOBEba/IPOL97HaYixBATmJl2dYn5KlWicqOyD2LzrAJTa9VD9juzmyj+Zg3X 7CMaWTh9Qjfnk87tqelR2YM24wsVIF/c0KwRDb+qSFRGe0Gar/AYKVleAClXv/hp CjaaX/Wr511ejEhbZSPu6CglsW5gu5SPlt6BEAlLc1OW7DknT6hFcVo4BqPeiUVP xlenxnv04TOcQQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtdeggddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfhhohhmrghsucfoohhnjhgrlhhonhcuoehthhhomhgrshes mhhonhhjrghlohhnrdhnvghtqeenucfkphepjeejrddufeegrddvtdefrddukeegnecurf grrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtnecu vehluhhsthgvrhfuihiivgeptd 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 896DC30607BE for ; Thu, 16 Jan 2020 02:17:11 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Date: Thu, 16 Jan 2020 08:16:55 +0100 Message-Id: <20200116071656.1663967-3-thomas@monjalon.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200116071656.1663967-1-thomas@monjalon.net> References: <20200116071656.1663967-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config 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" If a dependency is required for a driver build, but should not be exposed to the application (via pkg-config), it can be declared in the array hidden_deps. The hidden_deps are used as internal dependencies, when building the shared library and the first stage of static library. The final static library does not include the hidden_deps because this library object is used to generate the .pc file. Signed-off-by: Thomas Monjalon --- drivers/meson.build | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/meson.build b/drivers/meson.build index 3f8749d0b7..4ecd17ee01 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -56,6 +56,7 @@ foreach class:dpdk_driver_classes # too, so that it can be reflected in the pkgconfig output for # static builds. ext_deps = [] + hidden_deps = [] pkgconfig_extra_libs = [] # pull in driver directory which should assign to each of the above @@ -71,8 +72,9 @@ foreach class:dpdk_driver_classes endforeach if build # get dependency objs from strings - shared_deps = ext_deps - static_deps = ext_deps + shared_deps = ext_deps + hidden_deps + static_deps = ext_deps + hidden_deps + static_pub_deps = ext_deps foreach d:deps if not is_variable('shared_rte_' + d) build = false @@ -82,6 +84,7 @@ foreach class:dpdk_driver_classes else shared_deps += [get_variable('shared_rte_' + d)] static_deps += [get_variable('static_rte_' + d)] + static_pub_deps += [get_variable('static_rte_' + d)] endif endforeach endif @@ -144,7 +147,7 @@ foreach class:dpdk_driver_classes sources, objects: objs, include_directories: includes, - dependencies: static_deps, + dependencies: static_pub_deps, # skip hidden_deps c_args: cflags, install: true) From patchwork Thu Jan 16 07:16:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 64753 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 11D16A04F9; Thu, 16 Jan 2020 08:17:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9C1DF1C18F; Thu, 16 Jan 2020 08:17:16 +0100 (CET) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 8F8831C130 for ; Thu, 16 Jan 2020 08:17:15 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3CE8B220DB; Thu, 16 Jan 2020 02:17:15 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 16 Jan 2020 02:17:15 -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=JiZ+nUTg3M QAyBaxvM+S+cu02H4ygcfrnKYQ7v5VGpw=; b=jQTT1jXYecRDdU3H68Mj2K95Tp J4DQF7nNayS1IxnjUSPkdzBYXGnpRZS1f5fiyeR6Hfup6WdNaRvH7ZBMuDP2uQge gySj7ZQa22uApIH1npedlAm2NlxIJkpQHP0IFm+pYyeoINY5E0+SfeCl81Gk0cYr dGLx6A5mVIiwYV6fk= 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=JiZ+nUTg3MQAyBaxvM+S+cu02H4ygcfrnKYQ7v5VGpw=; b=GgRs6cHC ro17Bnhh0JWNgV5siJ92Qzu/AnrstIDr60RyBSKSrDfvSVsX1KT+Wx98tPFE/yW8 /j75vSaHZh5OW3AI+NN78rKx3hBDRT2k3MZCSKQreuveide8k5laQRPY81+g/cf7 2bIJAj+U5awo/mZ76D6s2eSARBtzPBTNkIDokSh2joMXCGgFcgSKBhunJmbsqqGL 1GPUNk+lDR2QuBHLvPeKGRcS7eoBlIDi8c9+Vfm6JlLn/M0bDyRz+e9KbQzKMK1G EdEP178tBPidgxpNzgV07ts5JHizWQDyg+/wBgSRwJ3irnnRRI7tp0l2C/VnP8B9 DTZewnSsv8kQiA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtdeggddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecuff homhgrihhnpehgihhthhhusgdrtghomhenucfkphepjeejrddufeegrddvtdefrddukeeg necurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvg htnecuvehluhhsthgvrhfuihiivgeptd 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 308FB306080E; Thu, 16 Jan 2020 02:17:14 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Matan Azrad , Shahaf Shuler , John McNamara , Marko Kovacevic , Viacheslav Ovsiienko , Bruce Richardson Date: Thu, 16 Jan 2020 08:16:56 +0100 Message-Id: <20200116071656.1663967-4-thomas@monjalon.net> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200116071656.1663967-1-thomas@monjalon.net> References: <20200116071656.1663967-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/3] net/mlx: support static ibverbs linkage with meson 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 libibverbs (and libmlx4/5) can be statically embedded in the shared PMD library, or in the application with the static PMD. It was supported with make build system in commit 2c0dd7b69fb0 ("config: add static linkage of mlx dependency"). The same feature is enabled with meson. The main difference, in meson build system, is the generated .pc file giving arguments to link DPDK with the application. Forcing meson to link with static dependencies is not really handled in meson and especially when generating a .pc file. A fix is in progress for meson, but anyway we will have to live without such a fix until a better version of meson is widely available: https://github.com/mesonbuild/meson/pull/6393 First, the static flavour must be explicitly picked thanks to the syntax -l:libfoo.a Second, in case DPDK is statically linked, the .pc file must not advertise the simple syntax -lfoo which would pick the shared library when linking the application. Signed-off-by: Thomas Monjalon --- buildtools/meson.build | 2 ++ doc/guides/nics/mlx4.rst | 4 ++++ doc/guides/nics/mlx5.rst | 4 ++++ drivers/net/mlx4/meson.build | 20 ++++++++++++++++---- drivers/net/mlx5/meson.build | 20 ++++++++++++++++---- meson_options.txt | 4 ++-- 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/buildtools/meson.build b/buildtools/meson.build index 6ef2c5721c..4ae427fae0 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -7,6 +7,8 @@ pmdinfo = find_program('gen-pmdinfo-cfile.sh') check_experimental_syms = find_program('check-experimental-syms.sh') +pkg_config_static = find_program('pkg-config-static.sh') + # set up map-to-def script using python, either built-in or external python3 = import('python').find_installation(required: false) if python3.found() diff --git a/doc/guides/nics/mlx4.rst b/doc/guides/nics/mlx4.rst index d0e8a8b2ff..4b1d1aceb2 100644 --- a/doc/guides/nics/mlx4.rst +++ b/doc/guides/nics/mlx4.rst @@ -92,6 +92,10 @@ These options can be modified in the ``.config`` file. adds additional run-time checks and debugging messages at the cost of lower performance. +This option is available in meson: + +- ``ibverbs_link`` can be ``static``, ``shared``, or ``dlopen``. + Environment variables ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 18573cf6a0..29a9d88b03 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -270,6 +270,10 @@ These options can be modified in the ``.config`` file. 64. Default armv8a configuration of make build and meson build set it to 128 then brings performance degradation. +This option is available in meson: + +- ``ibverbs_link`` can be ``static``, ``shared``, or ``dlopen``. + Environment variables ~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build index 9eb4988420..cdab360faa 100644 --- a/drivers/net/mlx4/meson.build +++ b/drivers/net/mlx4/meson.build @@ -9,6 +9,7 @@ if not is_linux endif build = true +static_ibverbs = (get_option('ibverbs_link') == 'static') pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so' LIB_GLUE_VERSION = '18.02.0' @@ -24,12 +25,24 @@ endif libnames = [ 'mlx4', 'ibverbs' ] libs = [] foreach libname:libnames - lib = dependency('lib' + libname, required:false) - if not lib.found() + lib = dependency('lib' + libname, static:static_ibverbs, required:false) + if not lib.found() and not static_ibverbs lib = cc.find_library(libname, required:false) endif if lib.found() - libs += [ lib ] + libs += lib + if static_ibverbs + # Workaround static dependency handling miss of meson + # See https://github.com/mesonbuild/meson/pull/6393 + # Build without adding shared libs to Requires.private + hidden_deps += lib.partial_dependency(compile_args:true) + # Add static lib deps to internal apps and Libs.private + ldflags = run_command(pkg_config_static, + 'lib' + libname, check:true).stdout() + ext_deps += declare_dependency(link_args:ldflags.split()) + else + ext_deps += lib + endif else build = false reason = 'missing dependency, "' + libname + '"' @@ -38,7 +51,6 @@ endforeach if build allow_experimental_apis = true - ext_deps += libs sources = files( 'mlx4.c', 'mlx4_ethdev.c', diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index d6b32db794..8ac604abd7 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -9,6 +9,7 @@ if not is_linux endif build = true +static_ibverbs = (get_option('ibverbs_link') == 'static') pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so' LIB_GLUE_VERSION = '19.08.0' @@ -24,12 +25,24 @@ endif libnames = [ 'mlx5', 'ibverbs' ] libs = [] foreach libname:libnames - lib = dependency('lib' + libname, required:false) - if not lib.found() + lib = dependency('lib' + libname, static:static_ibverbs, required:false) + if not lib.found() and not static_ibverbs lib = cc.find_library(libname, required:false) endif if lib.found() - libs += [ lib ] + libs += lib + if static_ibverbs + # Workaround static dependency handling miss of meson + # See https://github.com/mesonbuild/meson/pull/6393 + # Build without adding shared libs to Requires.private + hidden_deps += lib.partial_dependency(compile_args:true) + # Add static lib deps to internal apps and Libs.private + ldflags = run_command(pkg_config_static, + 'lib' + libname, check:true).stdout() + ext_deps += declare_dependency(link_args:ldflags.split()) + else + ext_deps += lib + endif else build = false reason = 'missing dependency, "' + libname + '"' @@ -39,7 +52,6 @@ endforeach if build allow_experimental_apis = true deps += ['hash'] - ext_deps += libs sources = files( 'mlx5.c', 'mlx5_ethdev.c', diff --git a/meson_options.txt b/meson_options.txt index bc369d06c9..0de16b4fdb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -12,8 +12,8 @@ option('examples', type: 'string', value: '', description: 'Comma-separated list of examples to build by default') option('flexran_sdk', type: 'string', value: '', description: 'Path to FlexRAN SDK optional Libraries for BBDEV device') -option('ibverbs_link', type: 'combo', choices : ['shared', 'dlopen'], value: 'shared', - description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.') +option('ibverbs_link', type: 'combo', choices : ['static', 'shared', 'dlopen'], value: 'shared', + description: 'Linkage method (static/shared/dlopen) for Mellanox PMDs with ibverbs dependencies.') option('include_subdir_arch', type: 'string', value: '', description: 'subdirectory where to install arch-dependent headers') option('kernel_dir', type: 'string', value: '',