summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2019-01-09 15:23:19 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2019-01-14 17:44:29 +0100
commit2c0dd7b69fb00fc3e422a6058ff8429edc869f68 (patch)
treefeeb13844b171079eaf058825c1fca2cfecb4b5c
parent72b934adce8f5f9ed035c04ebed8b386243e5a2e (diff)
downloaddpdk-2c0dd7b69fb00fc3e422a6058ff8429edc869f68.zip
dpdk-2c0dd7b69fb00fc3e422a6058ff8429edc869f68.tar.gz
dpdk-2c0dd7b69fb00fc3e422a6058ff8429edc869f68.tar.xz
config: add static linkage of mlx dependency
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 <thomas@monjalon.net> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
-rw-r--r--MAINTAINERS1
-rwxr-xr-xbuildtools/options-ibverbs-static.sh14
-rw-r--r--config/common_base3
-rw-r--r--doc/guides/nics/mlx4.rst18
-rw-r--r--doc/guides/nics/mlx5.rst18
-rw-r--r--drivers/net/mlx4/Makefile2
-rw-r--r--drivers/net/mlx5/Makefile2
-rw-r--r--mk/rte.app.mk4
8 files changed, 61 insertions, 1 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index cf11b21..0638f0f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -630,6 +630,7 @@ M: Shahaf Shuler <shahafs@mellanox.com>
M: Yongseok Koh <yskoh@mellanox.com>
T: git://dpdk.org/next/dpdk-next-net-mlx
F: drivers/net/mlx5/
+F: buildtools/options-ibverbs-static.sh
F: doc/guides/nics/mlx5.rst
F: doc/guides/nics/features/mlx5.ini
diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
new file mode 100755
index 0000000..0f285a3
--- /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 d2c214f..7c6da51 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 88d467a..4d4842c 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 749acd2..5ddca44 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 724a4dc..1f1b927 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 0938303..992769d 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -58,6 +58,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 97f1b7d..8a4f0f4 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -176,6 +176,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