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 <thomas@monjalon.net>
---
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(-)
@@ -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()
@@ -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
~~~~~~~~~~~~~~~~~~~~~
@@ -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
~~~~~~~~~~~~~~~~~~~~~
@@ -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',
@@ -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',
@@ -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: '',