net/mlx: add static ibverbs linkage with meson

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 2c0dd7b69f ("config: add static linkage of mlx dependency").

The same feature is enabled with meson when using pkg-config
(i.e. only if the call to dependency() is successful).
The fallback method for searching library with cc.find_library()
is not supported because the dependencies of the found library
would not be linked (no such info in .a file unlike .so).

The main difference, in meson build system, is the generated .pc file
giving arguments to link DPDK with the application.
Unfortunately the .pc file will not keep memory of the static linkage
option for libibverbs.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
Thomas Monjalon 2020-02-12 23:07:04 +01:00 committed by Ferruh Yigit
parent 79ece3649a
commit 6affeabaf3
5 changed files with 16 additions and 6 deletions

View File

@ -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 adds additional run-time checks and debugging messages at the cost of
lower performance. lower performance.
This option is available in meson:
- ``ibverbs_link`` can be ``static``, ``shared``, or ``dlopen``.
Environment variables Environment variables
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

View File

@ -275,6 +275,10 @@ These options can be modified in the ``.config`` file.
64. Default armv8a configuration of make build and meson build set it to 128 64. Default armv8a configuration of make build and meson build set it to 128
then brings performance degradation. then brings performance degradation.
This option is available in meson:
- ``ibverbs_link`` can be ``static``, ``shared``, or ``dlopen``.
Environment variables Environment variables
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

View File

@ -7,6 +7,7 @@ if not is_linux
subdir_done() subdir_done()
endif endif
static_ibverbs = (get_option('ibverbs_link') == 'static')
pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so' LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
LIB_GLUE_VERSION = '20.02.0' LIB_GLUE_VERSION = '20.02.0'
@ -22,8 +23,8 @@ endif
libnames = [ 'mlx5', 'ibverbs' ] libnames = [ 'mlx5', 'ibverbs' ]
libs = [] libs = []
foreach libname:libnames foreach libname:libnames
lib = dependency('lib' + libname, required:false) lib = dependency('lib' + libname, static:static_ibverbs, required:false)
if not lib.found() if not lib.found() and not static_ibverbs
lib = cc.find_library(libname, required:false) lib = cc.find_library(libname, required:false)
endif endif
if lib.found() if lib.found()

View File

@ -8,6 +8,7 @@ if not is_linux
subdir_done() subdir_done()
endif endif
static_ibverbs = (get_option('ibverbs_link') == 'static')
pmd_dlopen = (get_option('ibverbs_link') == 'dlopen') pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so' LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
LIB_GLUE_VERSION = '18.02.0' LIB_GLUE_VERSION = '18.02.0'
@ -23,8 +24,8 @@ endif
libnames = [ 'mlx4', 'ibverbs' ] libnames = [ 'mlx4', 'ibverbs' ]
libs = [] libs = []
foreach libname:libnames foreach libname:libnames
lib = dependency('lib' + libname, required:false) lib = dependency('lib' + libname, static:static_ibverbs, required:false)
if not lib.found() if not lib.found() and not static_ibverbs
lib = cc.find_library(libname, required:false) lib = cc.find_library(libname, required:false)
endif endif
if lib.found() if lib.found()

View File

@ -14,8 +14,8 @@ option('examples', type: 'string', value: '',
description: 'Comma-separated list of examples to build by default') description: 'Comma-separated list of examples to build by default')
option('flexran_sdk', type: 'string', value: '', option('flexran_sdk', type: 'string', value: '',
description: 'Path to FlexRAN SDK optional Libraries for BBDEV device') description: 'Path to FlexRAN SDK optional Libraries for BBDEV device')
option('ibverbs_link', type: 'combo', choices : ['shared', 'dlopen'], value: 'shared', option('ibverbs_link', type: 'combo', choices : ['static', 'shared', 'dlopen'], value: 'shared',
description: 'Linkage method (shared/dlopen) for Mellanox PMDs with ibverbs dependencies.') description: 'Linkage method (static/shared/dlopen) for Mellanox PMDs with ibverbs dependencies.')
option('include_subdir_arch', type: 'string', value: '', option('include_subdir_arch', type: 'string', value: '',
description: 'subdirectory where to install arch-dependent headers') description: 'subdirectory where to install arch-dependent headers')
option('kernel_dir', type: 'string', value: '', option('kernel_dir', type: 'string', value: '',