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