DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] add static ibverbs in meson
@ 2020-01-16  7:16 Thomas Monjalon
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script Thomas Monjalon
                   ` (5 more replies)
  0 siblings, 6 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-16  7:16 UTC (permalink / raw)
  To: dev

This is the follow-up of the feature I added one year ago:
static linkage of libibverbs in mlx PMDs.
The first implementation was focused on "make".
This second implementation works with "make" and "meson".


Thomas Monjalon (3):
  buildtools: rework static pkg-config script
  build: allow to hide dependencies from pkg-config
  net/mlx: support static ibverbs linkage with meson

 buildtools/meson.build               |  2 ++
 buildtools/options-ibverbs-static.sh | 14 -------------
 buildtools/pkg-config-static.sh      | 31 ++++++++++++++++++++++++++++
 doc/guides/nics/mlx4.rst             |  4 ++++
 doc/guides/nics/mlx5.rst             |  4 ++++
 drivers/meson.build                  |  9 +++++---
 drivers/net/mlx4/Makefile            |  2 +-
 drivers/net/mlx4/meson.build         | 20 ++++++++++++++----
 drivers/net/mlx5/Makefile            |  2 +-
 drivers/net/mlx5/meson.build         | 20 ++++++++++++++----
 meson_options.txt                    |  4 ++--
 mk/rte.app.mk                        |  3 ++-
 12 files changed, 85 insertions(+), 30 deletions(-)
 delete mode 100755 buildtools/options-ibverbs-static.sh
 create mode 100755 buildtools/pkg-config-static.sh

-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
@ 2020-01-16  7:16 ` Thomas Monjalon
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config Thomas Monjalon
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-16  7:16 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

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 <thomas@monjalon.net>
---
 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 <libname>
+#
+# 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
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script Thomas Monjalon
@ 2020-01-16  7:16 ` Thomas Monjalon
  2020-01-17 17:34   ` Bruce Richardson
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 3/3] net/mlx: support static ibverbs linkage with meson Thomas Monjalon
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-16  7:16 UTC (permalink / raw)
  To: 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 <thomas@monjalon.net>
---
 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)
 
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH 3/3] net/mlx: support static ibverbs linkage with meson
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script Thomas Monjalon
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config Thomas Monjalon
@ 2020-01-16  7:16 ` Thomas Monjalon
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-16  7:16 UTC (permalink / raw)
  To: dev
  Cc: Matan Azrad, Shahaf Shuler, John McNamara, Marko Kovacevic,
	Viacheslav Ovsiienko, Bruce Richardson

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(-)

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: '',
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config Thomas Monjalon
@ 2020-01-17 17:34   ` Bruce Richardson
  0 siblings, 0 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-01-17 17:34 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Thu, Jan 16, 2020 at 08:16:55AM +0100, Thomas Monjalon wrote:
> 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 <thomas@monjalon.net>
> ---
>  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 = []
>  
All parameters for drivers and libs need to be documented in the docs.

Thanks,
/Bruce

^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
                   ` (2 preceding siblings ...)
  2020-01-16  7:16 ` [dpdk-dev] [PATCH 3/3] net/mlx: support static ibverbs linkage with meson Thomas Monjalon
@ 2020-01-27 15:43 ` Thomas Monjalon
  2020-01-27 15:43   ` [dpdk-dev] [PATCH v2 1/4] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
                     ` (5 more replies)
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
  5 siblings, 6 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-27 15:43 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson

This is the follow-up of the feature I added one year ago:
static linkage of libibverbs in mlx PMDs.
The first implementation was focused on "make".
This second round does the same with "meson".


changes in v2:
- split mlx patch for normal addition and workarounds
- fix ldflags for ibverbs installed in a standard directory
- fix libs order leading to undefined references
- add doc for hidden_deps
- improve explanations in commit logs


Thomas Monjalon (4):
  net/mlx: add static ibverbs linkage with meson
  buildtools: get static mlx dependencies for meson
  build: allow hiding dependencies from pkg-config
  net/mlx: workaround static linkage with meson


 buildtools/meson.build                   |  2 ++
 buildtools/options-ibverbs-static.sh     | 10 ++++++++--
 doc/guides/contributing/coding_style.rst |  6 ++++++
 doc/guides/nics/mlx4.rst                 |  4 ++++
 doc/guides/nics/mlx5.rst                 |  4 ++++
 drivers/meson.build                      |  9 ++++++---
 drivers/net/mlx4/meson.build             | 19 +++++++++++++++----
 drivers/net/mlx5/meson.build             | 19 +++++++++++++++----
 meson_options.txt                        |  4 ++--
 9 files changed, 62 insertions(+), 15 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v2 1/4] net/mlx: add static ibverbs linkage with meson
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
@ 2020-01-27 15:43   ` Thomas Monjalon
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson Thomas Monjalon
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-27 15:43 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, John McNamara,
	Marko Kovacevic, Viacheslav Ovsiienko

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 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>
---
 doc/guides/nics/mlx4.rst     | 4 ++++
 doc/guides/nics/mlx5.rst     | 4 ++++
 drivers/net/mlx4/meson.build | 5 +++--
 drivers/net/mlx5/meson.build | 5 +++--
 meson_options.txt            | 4 ++--
 5 files changed, 16 insertions(+), 6 deletions(-)

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 66997f1ae7..b3bd3bba34 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -278,6 +278,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..51d9784ee2 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,8 +25,8 @@ 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()
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index 3ad4f02a53..a4f2f79f22 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 = '20.02.0'
@@ -24,8 +25,8 @@ 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()
diff --git a/meson_options.txt b/meson_options.txt
index 53dfe13c30..0a02f2faf9 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: '',
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
  2020-01-27 15:43   ` [dpdk-dev] [PATCH v2 1/4] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
@ 2020-01-27 15:44   ` Thomas Monjalon
  2020-01-29 15:37     ` Bruce Richardson
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 3/4] build: allow hiding dependencies from pkg-config Thomas Monjalon
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-27 15:44 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The shell script options-ibverbs-static.sh was used with make
in forcing static linkage of ibverbs libraries.

When choosing to link with a static dependency in meson,
the generated .pc file will not force such static linkage.
The solution will rely on using this script in meson.

If linking with libraries installed in a non-standard path,
an option -L is provided via EXTRA_LDFLAGS in case of using make.
With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
When statically linking an application, the .pc file must save the
-L path so the application link will work without any extra option.
That's why --libs-only-l is replaced with --libs which includes -L.
Options which are neither -l or -L are filtered out because not needed
and can cause compilation issues with the legacy system using make.

The other change in this script is to move the main library file
(libiverbs.a) at the end of the list of dependencies.
It fixes some undefined references when linking a static application
using libdpdk.pc.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/options-ibverbs-static.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
index 0f285a343b..43578a37f3 100755
--- a/buildtools/options-ibverbs-static.sh
+++ b/buildtools/options-ibverbs-static.sh
@@ -9,6 +9,12 @@
 #
 # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
 
-pkg-config --libs-only-l --static libibverbs |
+lib='libibverbs'
+deps='pthread|nl'
+
+pkg-config --libs --static $lib |
 	tr '[:space:]' '\n' |
-	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
+	sed -n '/^-[Ll]/p' |   # extra link options may break with make
+	sed "/$lib/d"   # move main lib at the end
+echo -l:$lib.a
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v2 3/4] build: allow hiding dependencies from pkg-config
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
  2020-01-27 15:43   ` [dpdk-dev] [PATCH v2 1/4] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-01-27 15:44   ` Thomas Monjalon
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 4/4] net/mlx: workaround static linkage with meson Thomas Monjalon
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-27 15:44 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, John McNamara, Marko Kovacevic

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 <thomas@monjalon.net>
---
 doc/guides/contributing/coding_style.rst | 6 ++++++
 drivers/meson.build                      | 9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 841ef6d5c8..c96457273f 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -975,6 +975,12 @@ deps
 ext_deps
 	As above.
 
+hidden_deps
+	**Default Value = []**.
+	Used to specify external dependencies, same as ``ext_deps``, except
+	the libraries won't be exposed as requirements of the static driver,
+	in the section ``Requires.private`` of the generated ``.pc`` file.
+
 includes
 	**Default Value = <driver directory>** Some drivers include a base
 	directory for additional source files and headers, so we have this
diff --git a/drivers/meson.build b/drivers/meson.build
index 29708cc2bb..759263c309 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)
 
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v2 4/4] net/mlx: workaround static linkage with meson
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
                     ` (2 preceding siblings ...)
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 3/4] build: allow hiding dependencies from pkg-config Thomas Monjalon
@ 2020-01-27 15:44   ` Thomas Monjalon
  2020-02-04 11:48   ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Bruce Richardson
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-27 15:44 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

If ibverbs_link is static and the application choose to link DPDK
as static libraries, both PMD and ibverbs libraries must be linked
as static libraries. And the dependencies of ibverbs (netlink) must
still be linked as shared libraries.

Unfortunately, meson forget about the static requirement for ibverbs
when generating the .pc file.
As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
section (allowing to be linked as shared libraries) and libnl is missing.

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

In order to not allow meson suggesting shared libraries in the section
Requires.private of the .pc file, the cflags are passed as hidden_deps.
The list of required dependencies is replaced with ldflags, forcing
static flavor of ibverbs libraries thanks to this syntax:
	-l:libfoo.a

Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/meson.build       |  2 ++
 drivers/net/mlx4/meson.build | 14 ++++++++++++--
 drivers/net/mlx5/meson.build | 14 ++++++++++++--
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index cd1d054036..2a25527385 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')
 
+ldflags_ibverbs_static = find_program('options-ibverbs-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/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 51d9784ee2..724256bfb4 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -30,16 +30,26 @@ foreach libname:libnames
 		lib = cc.find_library(libname, required:false)
 	endif
 	if lib.found()
-		libs += [ lib ]
+		libs += lib
+		if static_ibverbs
+			# Build without adding shared libs to Requires.private
+			hidden_deps += lib.partial_dependency(compile_args:true)
+		else
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
+if build and static_ibverbs
+	# Add static deps ldflags to internal apps and Libs.private
+	ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ldflags.split())
+endif
 
 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 a4f2f79f22..e04c8947e0 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -30,17 +30,27 @@ foreach libname:libnames
 		lib = cc.find_library(libname, required:false)
 	endif
 	if lib.found()
-		libs += [ lib ]
+		libs += lib
+		if static_ibverbs
+			# Build without adding shared libs to Requires.private
+			hidden_deps += lib.partial_dependency(compile_args:true)
+		else
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
+if build and static_ibverbs
+	# Add static deps ldflags to internal apps and Libs.private
+	ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ldflags.split())
+endif
 
 if build
 	allow_experimental_apis = true
 	deps += ['hash']
-	ext_deps += libs
 	sources = files(
 		'mlx5.c',
 		'mlx5_ethdev.c',
-- 
2.24.1


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-01-29 15:37     ` Bruce Richardson
  2020-01-29 17:48       ` Thomas Monjalon
  2020-01-29 17:48       ` Bruce Richardson
  0 siblings, 2 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-01-29 15:37 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Mon, Jan 27, 2020 at 04:44:00PM +0100, Thomas Monjalon wrote:
> The shell script options-ibverbs-static.sh was used with make
> in forcing static linkage of ibverbs libraries.
> 
> When choosing to link with a static dependency in meson,
> the generated .pc file will not force such static linkage.
> The solution will rely on using this script in meson.
> 
> If linking with libraries installed in a non-standard path,
> an option -L is provided via EXTRA_LDFLAGS in case of using make.
> With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
> When statically linking an application, the .pc file must save the
> -L path so the application link will work without any extra option.
> That's why --libs-only-l is replaced with --libs which includes -L.
> Options which are neither -l or -L are filtered out because not needed
> and can cause compilation issues with the legacy system using make.
> 
> The other change in this script is to move the main library file
> (libiverbs.a) at the end of the list of dependencies.
> It fixes some undefined references when linking a static application
> using libdpdk.pc.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  buildtools/options-ibverbs-static.sh | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
> index 0f285a343b..43578a37f3 100755
> --- a/buildtools/options-ibverbs-static.sh
> +++ b/buildtools/options-ibverbs-static.sh
> @@ -9,6 +9,12 @@
>  #
>  # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
>  
> -pkg-config --libs-only-l --static libibverbs |
> +lib='libibverbs'
> +deps='pthread|nl'
> +
> +pkg-config --libs --static $lib |
>  	tr '[:space:]' '\n' |
> -	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
> +	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
> +	sed -n '/^-[Ll]/p' |   # extra link options may break with make
> +	sed "/$lib/d"   # move main lib at the end
> +echo -l:$lib.a

To improve my understanding of the desired end result with this patchset
applied, I tried running different build configs with make with this patch
applied. I get a build error on my system with the following settings
adjusted from default (i.e. shared build with static link of ibverbs):

diff .config.orig .config
32c32
< CONFIG_RTE_BUILD_SHARED_LIB=n
---
> CONFIG_RTE_BUILD_SHARED_LIB=y
219c219
< CONFIG_RTE_LIBRTE_MLX5_PMD=n
---
> CONFIG_RTE_LIBRTE_MLX5_PMD=y
225c225
< CONFIG_RTE_IBVERBS_LINK_STATIC=n
---
> CONFIG_RTE_IBVERBS_LINK_STATIC=y

Error message I got is below. This is on Ubuntu 19.10 with gcc 9.2:

  LD librte_pmd_mlx5.so.20.0.1
/usr/bin/ld: /lib/x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GL
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[5]: *** [/home/bruce/dpdk.org/mk/rte.lib.mk:100: librte_pmd_mlx5.so.20.0.1] Error 1
make[4]: *** [/home/bruce/dpdk.org/mk/rte.subdir.mk:35: mlx5] Error 2
make[3]: *** [/home/bruce/dpdk.org/mk/rte.subdir.mk:35: net] Error 2
make[2]: *** [/home/bruce/dpdk.org/mk/rte.sdkbuild.mk:48: drivers] Error 2
make[1]: *** [/home/bruce/dpdk.org/mk/rte.sdkroot.mk:99: all] Error 2
make: *** [Makefile:12: all] Error 2


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-29 15:37     ` Bruce Richardson
@ 2020-01-29 17:48       ` Thomas Monjalon
  2020-01-29 17:50         ` Bruce Richardson
  2020-01-29 17:48       ` Bruce Richardson
  1 sibling, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-29 17:48 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

29/01/2020 16:37, Bruce Richardson:
> Error message I got is below. This is on Ubuntu 19.10 with gcc 9.2:
> 
>   LD librte_pmd_mlx5.so.20.0.1
> /usr/bin/ld: /lib/x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GL

I think -fPIC is missing.
Which version of rdma-core is it?
As documented, you may have to build the static libraries yourself:
	http://doc.dpdk.org/guides/nics/mlx5.html#installation
	CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja .. && ninja




^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-29 15:37     ` Bruce Richardson
  2020-01-29 17:48       ` Thomas Monjalon
@ 2020-01-29 17:48       ` Bruce Richardson
  1 sibling, 0 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-01-29 17:48 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Wed, Jan 29, 2020 at 03:37:51PM +0000, Bruce Richardson wrote:
> On Mon, Jan 27, 2020 at 04:44:00PM +0100, Thomas Monjalon wrote:
> > The shell script options-ibverbs-static.sh was used with make
> > in forcing static linkage of ibverbs libraries.
> > 
> > When choosing to link with a static dependency in meson,
> > the generated .pc file will not force such static linkage.
> > The solution will rely on using this script in meson.
> > 
> > If linking with libraries installed in a non-standard path,
> > an option -L is provided via EXTRA_LDFLAGS in case of using make.
> > With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
> > When statically linking an application, the .pc file must save the
> > -L path so the application link will work without any extra option.
> > That's why --libs-only-l is replaced with --libs which includes -L.
> > Options which are neither -l or -L are filtered out because not needed
> > and can cause compilation issues with the legacy system using make.
> > 
> > The other change in this script is to move the main library file
> > (libiverbs.a) at the end of the list of dependencies.
> > It fixes some undefined references when linking a static application
> > using libdpdk.pc.
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> >  buildtools/options-ibverbs-static.sh | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
> > index 0f285a343b..43578a37f3 100755
> > --- a/buildtools/options-ibverbs-static.sh
> > +++ b/buildtools/options-ibverbs-static.sh
> > @@ -9,6 +9,12 @@
> >  #
> >  # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
> >  
> > -pkg-config --libs-only-l --static libibverbs |
> > +lib='libibverbs'
> > +deps='pthread|nl'
> > +
> > +pkg-config --libs --static $lib |
> >  	tr '[:space:]' '\n' |
> > -	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
> > +	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
> > +	sed -n '/^-[Ll]/p' |   # extra link options may break with make
> > +	sed "/$lib/d"   # move main lib at the end
> > +echo -l:$lib.a
> 
> To improve my understanding of the desired end result with this patchset
> applied, I tried running different build configs with make with this patch
> applied. I get a build error on my system with the following settings
> adjusted from default (i.e. shared build with static link of ibverbs):
> 
> diff .config.orig .config
> 32c32
> < CONFIG_RTE_BUILD_SHARED_LIB=n
> ---
> > CONFIG_RTE_BUILD_SHARED_LIB=y
> 219c219
> < CONFIG_RTE_LIBRTE_MLX5_PMD=n
> ---
> > CONFIG_RTE_LIBRTE_MLX5_PMD=y
> 225c225
> < CONFIG_RTE_IBVERBS_LINK_STATIC=n
> ---
> > CONFIG_RTE_IBVERBS_LINK_STATIC=y
> 
> Error message I got is below. This is on Ubuntu 19.10 with gcc 9.2:
> 
>   LD librte_pmd_mlx5.so.20.0.1
> /usr/bin/ld: /lib/x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GL
> /usr/bin/ld: final link failed: bad value
> collect2: error: ld returned 1 exit status
> make[5]: *** [/home/bruce/dpdk.org/mk/rte.lib.mk:100: librte_pmd_mlx5.so.20.0.1] Error 1
> make[4]: *** [/home/bruce/dpdk.org/mk/rte.subdir.mk:35: mlx5] Error 2
> make[3]: *** [/home/bruce/dpdk.org/mk/rte.subdir.mk:35: net] Error 2
> make[2]: *** [/home/bruce/dpdk.org/mk/rte.sdkbuild.mk:48: drivers] Error 2
> make[1]: *** [/home/bruce/dpdk.org/mk/rte.sdkroot.mk:99: all] Error 2
> make: *** [Makefile:12: all] Error 2
> 

After applying all 4 patches, and testing with meson, I see the same issue.
It appears that the mlx4/5.a files in Ubuntu are not relocatable for
including in a shared library.

/Bruce

[1/2] Linking target drivers/librte_pmd_mlx4.so.20.0.1.
FAILED: drivers/librte_pmd_mlx4.so.20.0.1
cc  -o drivers/librte_pmd_mlx4.so.20.0.1 'drivers/a715181@@rte_pmd_mlx4@sha/meson-generated_.._rte_pmd_mlx4.pmd.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_ethdev.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_flow.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_intr.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_mp.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_mr.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_rxq.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_rxtx.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_txq.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_utils.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx4@sta/net_mlx4_mlx4_glue.c.o' -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,librte_pmd_mlx4.so.20.0 -Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_ethdev.so.20.0.1 lib/librte_eal.so.20.0.1 lib/librte_kvargs.so.20.0.1 lib/librte_net.so.20.0.1 lib/librte_mbuf.so.20.0.1 lib/librte_mempool.so.20.0.1 lib/librte_ring.so.20.0.1 lib/librte_meter.so.20.0.1 drivers/librte_bus_pci.so.20.0.1 lib/librte_pci.so.20.0.1 drivers/librte_bus_vdev.so.20.0.1 -Wl,--version-script=/home/bruce/dpdk.org/drivers/net/mlx4/rte_pmd_mlx4_version.map -lpthread -l:libbnxt_re-rdmav22.a -l:libcxgb3-rdmav22.a -l:libcxgb4-rdmav22.a -l:libefa.a -l:libhns-rdmav22.a -l:libi40iw-rdmav22.a -l:libmlx4.a -l:libmlx5.a -l:libmthca-rdmav22.a -l:libnes-rdmav22.a -l:libocrdma-rdmav22.a -l:libqedr-rdmav22.a -l:libvmw_pvrdma-rdmav22.a -l:libhfi1verbs-rdmav22.a -l:libipathverbs-rdmav22.a -l:librxe-rdmav22.a -lnl-route-3 -lnl-3 -l:libibverbs.a /usr/lib/x86_64-linux-gnu/libbsd.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib -Wl,-rpath-link,/home/bruce/dpdk.org/build/drivers
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libmlx4.a(mlx4.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
[2/2] Linking target drivers/librte_pmd_mlx5.so.20.0.1.
FAILED: drivers/librte_pmd_mlx5.so.20.0.1
cc  -o drivers/librte_pmd_mlx5.so.20.0.1 'drivers/a715181@@rte_pmd_mlx5@sha/meson-generated_.._rte_pmd_mlx5.pmd.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_ethdev.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_flow.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_flow_meter.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_flow_dv.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_flow_verbs.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_mac.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_mr.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_nl.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_rss.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_rxmode.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_rxq.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_rxtx.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_mp.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_stats.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_trigger.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_txq.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_vlan.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_devx_cmds.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_utils.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_socket.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_rxtx_vec.c.o' 'drivers/a715181@@tmp_rte_pmd_mlx5@sta/net_mlx5_mlx5_glue.c.o' -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,librte_pmd_mlx5.so.20.0 -Wl,--no-as-needed -pthread -lm -ldl -lnuma lib/librte_ethdev.so.20.0.1 lib/librte_eal.so.20.0.1 lib/librte_kvargs.so.20.0.1 lib/librte_net.so.20.0.1 lib/librte_mbuf.so.20.0.1 lib/librte_mempool.so.20.0.1 lib/librte_ring.so.20.0.1 lib/librte_meter.so.20.0.1 drivers/librte_bus_pci.so.20.0.1 lib/librte_pci.so.20.0.1 drivers/librte_bus_vdev.so.20.0.1 lib/librte_hash.so.20.0.1 -Wl,--version-script=/home/bruce/dpdk.org/drivers/net/mlx5/rte_pmd_mlx5_version.map -lpthread -l:libbnxt_re-rdmav22.a -l:libcxgb3-rdmav22.a -l:libcxgb4-rdmav22.a -l:libefa.a -l:libhns-rdmav22.a -l:libi40iw-rdmav22.a -l:libmlx4.a -l:libmlx5.a -l:libmthca-rdmav22.a -l:libnes-rdmav22.a -l:libocrdma-rdmav22.a -l:libqedr-rdmav22.a -l:libvmw_pvrdma-rdmav22.a -l:libhfi1verbs-rdmav22.a -l:libipathverbs-rdmav22.a -l:librxe-rdmav22.a -lnl-route-3 -lnl-3 -l:libibverbs.a /usr/lib/x86_64-linux-gnu/libbsd.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/' -Wl,-rpath-link,/home/bruce/dpdk.org/build/lib -Wl,-rpath-link,/home/bruce/dpdk.org/build/drivers
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-29 17:48       ` Thomas Monjalon
@ 2020-01-29 17:50         ` Bruce Richardson
  2020-01-29 18:49           ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2020-01-29 17:50 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Wed, Jan 29, 2020 at 06:48:14PM +0100, Thomas Monjalon wrote:
> 29/01/2020 16:37, Bruce Richardson:
> > Error message I got is below. This is on Ubuntu 19.10 with gcc 9.2:
> > 
> >   LD librte_pmd_mlx5.so.20.0.1
> > /usr/bin/ld: /lib/x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GL
> 
> I think -fPIC is missing.
> Which version of rdma-core is it?
> As documented, you may have to build the static libraries yourself:
> 	http://doc.dpdk.org/guides/nics/mlx5.html#installation
> 	CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja .. && ninja
> 
Yes, that appears to be necessary. :-(

What is the big advantage of doing this over default linking using standard
packages, especially since for end apps the pkg-config file is taking care
of providing all the correct linker args?

/Bruce

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson
  2020-01-29 17:50         ` Bruce Richardson
@ 2020-01-29 18:49           ` Thomas Monjalon
  0 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-01-29 18:49 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

29/01/2020 18:50, Bruce Richardson:
> On Wed, Jan 29, 2020 at 06:48:14PM +0100, Thomas Monjalon wrote:
> > 29/01/2020 16:37, Bruce Richardson:
> > > Error message I got is below. This is on Ubuntu 19.10 with gcc 9.2:
> > > 
> > >   LD librte_pmd_mlx5.so.20.0.1
> > > /usr/bin/ld: /lib/x86_64-linux-gnu/libmlx5.a(mlx5.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GL
> > 
> > I think -fPIC is missing.
> > Which version of rdma-core is it?
> > As documented, you may have to build the static libraries yourself:
> > 	http://doc.dpdk.org/guides/nics/mlx5.html#installation
> > 	CFLAGS=-fPIC cmake -DIN_PLACE=1 -DENABLE_STATIC=1 -GNinja .. && ninja
> > 
> Yes, that appears to be necessary. :-(
> 
> What is the big advantage of doing this over default linking using standard
> packages, especially since for end apps the pkg-config file is taking care
> of providing all the correct linker args?

It does not change anything for compilation. It's all about packaging.
It may be easier to package in some environments, by removing one dependency.




^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
                     ` (3 preceding siblings ...)
  2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 4/4] net/mlx: workaround static linkage with meson Thomas Monjalon
@ 2020-02-04 11:48   ` Bruce Richardson
  2020-02-04 14:27     ` Thomas Monjalon
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
  5 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2020-02-04 11:48 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Mon, Jan 27, 2020 at 04:43:58PM +0100, Thomas Monjalon wrote:
> This is the follow-up of the feature I added one year ago:
> static linkage of libibverbs in mlx PMDs.
> The first implementation was focused on "make".
> This second round does the same with "meson".
> 
> 
> changes in v2:
> - split mlx patch for normal addition and workarounds
> - fix ldflags for ibverbs installed in a standard directory
> - fix libs order leading to undefined references
> - add doc for hidden_deps
> - improve explanations in commit logs
> 
> 
> Thomas Monjalon (4):
>   net/mlx: add static ibverbs linkage with meson
>   buildtools: get static mlx dependencies for meson
>   build: allow hiding dependencies from pkg-config
>   net/mlx: workaround static linkage with meson
> 
> 
Hi Thomas,

as we discussed offline, I really don't like the necessity of the
hidden_deps part of this, so I've tried coming up with some other
solutions. For example, in my testing I get the same result with the
following diff instead of the second two patches (just showing for mlx5 -
changes for mlx4 are identical):

--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -31,10 +31,7 @@ foreach libname:libnames
        endif
        if lib.found()
                libs += lib
-               if static_ibverbs
-                       # Build without adding shared libs to Requires.private
-                       hidden_deps += lib.partial_dependency(compile_args:true)
-               else
+               if not static_ibverbs
                        ext_deps += lib
                endif
        else
@@ -44,8 +41,10 @@ foreach libname:libnames
 endforeach
 if build and static_ibverbs
        # Add static deps ldflags to internal apps and Libs.private
-       ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
-       ext_deps += declare_dependency(link_args:ldflags.split())
+       ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+       ibv_cflags = run_command(find_program('pkg-config'), '--cflags', 'libibverbs').stdout()
+       ext_deps += declare_dependency(compile_args: ibv_cflags.split(),
+                               link_args:ibv_ldflags.split())
 endif
 
 if build


By doing things this way - assuming it works in your tests too - we avoid
any need to change anything in the common drivers code.

How I tested this was by:
* doing a local rdma-core build as described in the docs and exporting
  PKG_CONFIG_PATH to point to the .pc file
* doing builds with all 4 of your patches applied (one static linking of
  apps, one shared, just in case)
* doing builds with the first two patches and the above diff.
* compare the meson.build files and libdpdk.pc files for the two cases. In
  my tests the second case as additional -I flags, but otherwise identical.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-02-04 11:48   ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Bruce Richardson
@ 2020-02-04 14:27     ` Thomas Monjalon
  2020-02-04 14:33       ` Bruce Richardson
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-04 14:27 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

04/02/2020 12:48, Bruce Richardson:
> as we discussed offline, I really don't like the necessity of the
> hidden_deps part of this, so I've tried coming up with some other
> solutions.

Thanks for looking closely at these patches.

> For example, in my testing I get the same result with the
> following diff instead of the second two patches (just showing for mlx5 -
> changes for mlx4 are identical):
[...]
> -                       # Build without adding shared libs to Requires.private
> -                       hidden_deps += lib.partial_dependency(compile_args:true)
[...]
> +       ibv_cflags = run_command(find_program('pkg-config'), '--cflags', 'libibverbs').stdout()
[...]
> By doing things this way - assuming it works in your tests too - we avoid
> any need to change anything in the common drivers code.

Yes, you hide the dependency by getting cflags directly with pkg-config.
I wanted to avoid such solution because I was trying to use as much
as possible the meson infrastructure.

I think your solution relying on one more call to pkg-config is acceptable.
I will test it and will review whether we get all corner cases.

In the meantime I discovered we are overlinking with meson
when using the dlopen linking option.
I will try to fix it as well with the same method.

Thanks



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-02-04 14:27     ` Thomas Monjalon
@ 2020-02-04 14:33       ` Bruce Richardson
  2020-02-04 15:14         ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2020-02-04 14:33 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Feb 04, 2020 at 03:27:50PM +0100, Thomas Monjalon wrote:
> 04/02/2020 12:48, Bruce Richardson:
> > as we discussed offline, I really don't like the necessity of the
> > hidden_deps part of this, so I've tried coming up with some other
> > solutions.
> 
> Thanks for looking closely at these patches.
> 
> > For example, in my testing I get the same result with the
> > following diff instead of the second two patches (just showing for mlx5 -
> > changes for mlx4 are identical):
> [...]
> > -                       # Build without adding shared libs to Requires.private
> > -                       hidden_deps += lib.partial_dependency(compile_args:true)
> [...]
> > +       ibv_cflags = run_command(find_program('pkg-config'), '--cflags', 'libibverbs').stdout()
> [...]
> > By doing things this way - assuming it works in your tests too - we avoid
> > any need to change anything in the common drivers code.
> 
> Yes, you hide the dependency by getting cflags directly with pkg-config.
> I wanted to avoid such solution because I was trying to use as much
> as possible the meson infrastructure.
> 
> I think your solution relying on one more call to pkg-config is acceptable.
> I will test it and will review whether we get all corner cases.
> 

Thanks.
It's not really ideal, but this is likely always going to be a bit flakey
since we can't use distro-supplied .a files, and your scripting is needed
to prevent even accidentally taking a non-custom-build rdma-core file.
Furthermore, I see that while meson tracks PKG_CONFIG_PATH value itself for
finding things, this does not get tracked between runs for shell calls.
This can catch one out, for example:

PKG_CONFIG_PATH=/path/to/pc/files meson build

will work correctly for everything. However, if one does a reconfigure
subsequently doing e.g. ninja reconfigure, meson will correctly pick up the
.pc files, but the ibverbs-static script, or any run_command calls to
pkg-config won't as it's not actually in the environment :-(

> In the meantime I discovered we are overlinking with meson
> when using the dlopen linking option.
> I will try to fix it as well with the same method.
> 
Right. Overlinking is probably less serious an issue though. Does it cause
any real-world problems?

/Bruce

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-02-04 14:33       ` Bruce Richardson
@ 2020-02-04 15:14         ` Thomas Monjalon
  2020-02-04 15:20           ` Bruce Richardson
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-04 15:14 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

04/02/2020 15:33, Bruce Richardson:
> On Tue, Feb 04, 2020 at 03:27:50PM +0100, Thomas Monjalon wrote:
> > 04/02/2020 12:48, Bruce Richardson:
> > > as we discussed offline, I really don't like the necessity of the
> > > hidden_deps part of this, so I've tried coming up with some other
> > > solutions.
> > 
> > Thanks for looking closely at these patches.
> > 
> > > For example, in my testing I get the same result with the
> > > following diff instead of the second two patches (just showing for mlx5 -
> > > changes for mlx4 are identical):
> > [...]
> > > -                       # Build without adding shared libs to Requires.private
> > > -                       hidden_deps += lib.partial_dependency(compile_args:true)
> > [...]
> > > +       ibv_cflags = run_command(find_program('pkg-config'), '--cflags', 'libibverbs').stdout()
> > [...]
> > > By doing things this way - assuming it works in your tests too - we avoid
> > > any need to change anything in the common drivers code.
> > 
> > Yes, you hide the dependency by getting cflags directly with pkg-config.
> > I wanted to avoid such solution because I was trying to use as much
> > as possible the meson infrastructure.
> > 
> > I think your solution relying on one more call to pkg-config is acceptable.
> > I will test it and will review whether we get all corner cases.
> > 
> 
> Thanks.
> It's not really ideal, but this is likely always going to be a bit flakey
> since we can't use distro-supplied .a files, and your scripting is needed
> to prevent even accidentally taking a non-custom-build rdma-core file.
> Furthermore, I see that while meson tracks PKG_CONFIG_PATH value itself for
> finding things, this does not get tracked between runs for shell calls.
> This can catch one out, for example:
> 
> PKG_CONFIG_PATH=/path/to/pc/files meson build
> 
> will work correctly for everything. However, if one does a reconfigure
> subsequently doing e.g. ninja reconfigure, meson will correctly pick up the
> .pc files, but the ibverbs-static script, or any run_command calls to
> pkg-config won't as it's not actually in the environment :-(

In my setup, I export PKG_CONFIG_PATH, so it is not an issue.
But I understand your point that we may hit the issue.
That's why I will work in meson upstream to avoid all of this in future.


> > In the meantime I discovered we are overlinking with meson
> > when using the dlopen linking option.
> > I will try to fix it as well with the same method.
> > 
> Right. Overlinking is probably less serious an issue though. Does it cause
> any real-world problems?

Overlinking defeats the benefit of dlopen.
The idea of dlopen is to avoid having ibverbs as mandatory DPDK dependency.
The ibverbs lib is loaded with dlopen only if probing a Mellanox device.
The dlopen solution makes the PMD really like an optional plugin,
same as for static linkage in the PMD.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson
  2020-02-04 15:14         ` Thomas Monjalon
@ 2020-02-04 15:20           ` Bruce Richardson
  0 siblings, 0 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-02-04 15:20 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Feb 04, 2020 at 04:14:46PM +0100, Thomas Monjalon wrote:
> 04/02/2020 15:33, Bruce Richardson:
> > On Tue, Feb 04, 2020 at 03:27:50PM +0100, Thomas Monjalon wrote:
> > > 04/02/2020 12:48, Bruce Richardson:
> > > > as we discussed offline, I really don't like the necessity of the
> > > > hidden_deps part of this, so I've tried coming up with some other
> > > > solutions.
> > > 
> > > Thanks for looking closely at these patches.
> > > 
> > > > For example, in my testing I get the same result with the
> > > > following diff instead of the second two patches (just showing for mlx5 -
> > > > changes for mlx4 are identical):
> > > [...]
> > > > -                       # Build without adding shared libs to Requires.private
> > > > -                       hidden_deps += lib.partial_dependency(compile_args:true)
> > > [...]
> > > > +       ibv_cflags = run_command(find_program('pkg-config'), '--cflags', 'libibverbs').stdout()
> > > [...]
> > > > By doing things this way - assuming it works in your tests too - we avoid
> > > > any need to change anything in the common drivers code.
> > > 
> > > Yes, you hide the dependency by getting cflags directly with pkg-config.
> > > I wanted to avoid such solution because I was trying to use as much
> > > as possible the meson infrastructure.
> > > 
> > > I think your solution relying on one more call to pkg-config is acceptable.
> > > I will test it and will review whether we get all corner cases.
> > > 
> > 
> > Thanks.
> > It's not really ideal, but this is likely always going to be a bit flakey
> > since we can't use distro-supplied .a files, and your scripting is needed
> > to prevent even accidentally taking a non-custom-build rdma-core file.
> > Furthermore, I see that while meson tracks PKG_CONFIG_PATH value itself for
> > finding things, this does not get tracked between runs for shell calls.
> > This can catch one out, for example:
> > 
> > PKG_CONFIG_PATH=/path/to/pc/files meson build
> > 
> > will work correctly for everything. However, if one does a reconfigure
> > subsequently doing e.g. ninja reconfigure, meson will correctly pick up the
> > .pc files, but the ibverbs-static script, or any run_command calls to
> > pkg-config won't as it's not actually in the environment :-(
> 
> In my setup, I export PKG_CONFIG_PATH, so it is not an issue.
> But I understand your point that we may hit the issue.
> That's why I will work in meson upstream to avoid all of this in future.
> 
+1

> 
> > > In the meantime I discovered we are overlinking with meson
> > > when using the dlopen linking option.
> > > I will try to fix it as well with the same method.
> > > 
> > Right. Overlinking is probably less serious an issue though. Does it cause
> > any real-world problems?
> 
> Overlinking defeats the benefit of dlopen.
> The idea of dlopen is to avoid having ibverbs as mandatory DPDK dependency.
> The ibverbs lib is loaded with dlopen only if probing a Mellanox device.
> The dlopen solution makes the PMD really like an optional plugin,
> same as for static linkage in the PMD.
> 
Right, I understand the issue now.

^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking in meson
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
                     ` (4 preceding siblings ...)
  2020-02-04 11:48   ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Bruce Richardson
@ 2020-02-11  1:19   ` Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 1/5] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
                       ` (5 more replies)
  5 siblings, 6 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson

This is the follow-up of the feature I added one year ago:
static linkage of libibverbs in mlx PMDs.
The first implementation was focused on "make".
This second round does the same with "meson".

With the meson option ibverbs_link, only the mode "shared"
was working correctly.
This patchset adds the mode "static" and fixes the mode "dlopen".


changes in v3:
- get cflags with pkg-config invocation
- drop addition of global variable hidden_deps
- remove overlinking in dlopen mode

changes in v2:
- split mlx patch for normal addition and workarounds
- fix ldflags for ibverbs installed in a standard directory
- fix libs order leading to undefined references
- add doc for hidden_deps
- improve explanations in commit logs


Thomas Monjalon (5):
  net/mlx: add static ibverbs linkage with meson
  buildtools: get static mlx dependencies for meson
  net/mlx: workaround static linkage with meson
  net/mlx: rename meson variable for dlopen option
  net/mlx: fix overlinking with meson and glue dlopen

 buildtools/meson.build               |  2 ++
 buildtools/options-ibverbs-static.sh | 10 ++++++++--
 doc/guides/nics/mlx4.rst             |  4 ++++
 doc/guides/nics/mlx5.rst             |  4 ++++
 drivers/common/mlx5/meson.build      | 27 +++++++++++++++++++-------
 drivers/net/mlx4/meson.build         | 29 ++++++++++++++++++++--------
 meson_options.txt                    |  4 ++--
 7 files changed, 61 insertions(+), 19 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 1/5] net/mlx: add static ibverbs linkage with meson
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
@ 2020-02-11  1:19     ` Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 2/5] buildtools: get static mlx dependencies for meson Thomas Monjalon
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, John McNamara,
	Marko Kovacevic, Viacheslav Ovsiienko

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 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>
---
 doc/guides/nics/mlx4.rst        | 4 ++++
 doc/guides/nics/mlx5.rst        | 4 ++++
 drivers/common/mlx5/meson.build | 5 +++--
 drivers/net/mlx4/meson.build    | 5 +++--
 meson_options.txt               | 4 ++--
 5 files changed, 16 insertions(+), 6 deletions(-)

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 2411fb3461..ffab34d281 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -278,6 +278,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/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 9cbd527cae..f24e421bc3 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -8,6 +8,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 = '20.02.0'
@@ -23,8 +24,8 @@ 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()
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 0260c5dc59..8696f6ebdf 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,8 +25,8 @@ 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()
diff --git a/meson_options.txt b/meson_options.txt
index 20be15fe6b..9e4923a4f1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -14,8 +14,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: '',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 2/5] buildtools: get static mlx dependencies for meson
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 1/5] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
@ 2020-02-11  1:19     ` Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson Thomas Monjalon
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The shell script options-ibverbs-static.sh was used with make
in forcing static linkage of ibverbs libraries.

When choosing to link with a static dependency in meson,
the generated .pc file will not force such static linkage.
The solution will rely on using this script in meson.

If linking with libraries installed in a non-standard path,
an option -L is provided via EXTRA_LDFLAGS in case of using make.
With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
When statically linking an application, the .pc file must save the
-L path so the application link will work without any extra option.
That's why --libs-only-l is replaced with --libs which includes -L.
Options which are neither -l or -L are filtered out because not needed
and can cause compilation issues with the legacy system using make.

The other change in this script is to move the main library file
(libiverbs.a) at the end of the list of dependencies.
It fixes some undefined references when linking a static application
using libdpdk.pc.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/options-ibverbs-static.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
index 0f285a343b..43578a37f3 100755
--- a/buildtools/options-ibverbs-static.sh
+++ b/buildtools/options-ibverbs-static.sh
@@ -9,6 +9,12 @@
 #
 # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
 
-pkg-config --libs-only-l --static libibverbs |
+lib='libibverbs'
+deps='pthread|nl'
+
+pkg-config --libs --static $lib |
 	tr '[:space:]' '\n' |
-	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
+	sed -n '/^-[Ll]/p' |   # extra link options may break with make
+	sed "/$lib/d"   # move main lib at the end
+echo -l:$lib.a
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 1/5] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 2/5] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-02-11  1:19     ` Thomas Monjalon
  2020-02-11 11:29       ` Bruce Richardson
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 4/5] net/mlx: rename meson variable for dlopen option Thomas Monjalon
                       ` (2 subsequent siblings)
  5 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

If ibverbs_link is static and the application choose to link DPDK
as static libraries, both PMD and ibverbs libraries must be linked
as static libraries. And the dependencies of ibverbs (netlink) must
still be linked as shared libraries.

Unfortunately, meson forget about the static requirement for ibverbs
when generating the .pc file.
As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
section (allowing to be linked as shared libraries) and libnl is missing.

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

In order to avoid meson suggesting shared libraries in the section
Requires.private of the .pc file, the dependency object is recreated
with declare_dependency():
	- cflags are extracted the libibverbs.pc
	- ldflags, from libibverbs.pc, are processed to force
	static flavor of ibverbs libraries, thanks to this syntax:
			-l:libfoo.a

Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/meson.build          |  2 ++
 drivers/common/mlx5/meson.build | 12 +++++++++++-
 drivers/net/mlx4/meson.build    | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index 0f563d89a3..4e3541b0d7 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -3,9 +3,11 @@
 
 subdir('pmdinfogen')
 
+pkgconf = find_program('pkg-config', 'pkgconf')
 pmdinfo = find_program('gen-pmdinfo-cfile.sh')
 list_dir_globs = find_program('list-dir-globs.py')
 check_experimental_syms = find_program('check-experimental-syms.sh')
+ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
 
 # set up map-to-def script using python, either built-in or external
 python3 = import('python').find_installation(required: false)
diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index f24e421bc3..bf04d16d76 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -30,16 +30,26 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
+if build and static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 if build
 	allow_experimental_apis = true
 	deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
-	ext_deps += libs
 	sources = files(
 		'mlx5_devx_cmds.c',
 		'mlx5_common.c',
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 8696f6ebdf..cf53a6b3e1 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -30,16 +30,26 @@ foreach libname:libnames
 		lib = cc.find_library(libname, required:false)
 	endif
 	if lib.found()
-		libs += [ lib ]
+		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
+if build and static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 if build
 	allow_experimental_apis = true
-	ext_deps += libs
 	sources = files(
 		'mlx4.c',
 		'mlx4_ethdev.c',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 4/5] net/mlx: rename meson variable for dlopen option
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
                       ` (2 preceding siblings ...)
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson Thomas Monjalon
@ 2020-02-11  1:19     ` Thomas Monjalon
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
  2020-02-11 11:33     ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking in meson Bruce Richardson
  5 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The name of the variable pmd_dlopen is confusing because
it can be understood as true if the PMD is dlopen,
whereas it means the ibverbs glue layer is a dlopen library.
That's why it is renamed dlopen_ibverbs.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 8 ++++----
 drivers/net/mlx4/meson.build    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index bf04d16d76..2bb2a83c45 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -9,11 +9,11 @@ endif
 build = true
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '20.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
@@ -55,7 +55,7 @@ if build
 		'mlx5_common.c',
 		'mlx5_nl.c',
 	)
-	if not pmd_dlopen
+	if not dlopen_ibverbs
 		sources += files('mlx5_glue.c')
 	endif
 	cflags_options = [
@@ -194,7 +194,7 @@ if build
 	configure_file(output : 'mlx5_autoconf.h', configuration : config)
 endif
 # Build Glue Library
-if pmd_dlopen and build
+if dlopen_ibverbs and build
 	dlopen_name = 'mlx5_glue'
 	dlopen_lib_name = 'rte_pmd_@0@'.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index cf53a6b3e1..2970f395c1 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -10,11 +10,11 @@ endif
 build = true
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
@@ -62,7 +62,7 @@ if build
 		'mlx4_txq.c',
 		'mlx4_utils.c',
 	)
-	if not pmd_dlopen
+	if not dlopen_ibverbs
 		sources += files('mlx4_glue.c')
 	endif
 	cflags_options = [
@@ -114,7 +114,7 @@ if build
 	configure_file(output : 'mlx4_autoconf.h', configuration : config)
 endif
 # Build Glue Library
-if pmd_dlopen and build
+if dlopen_ibverbs and build
 	dlopen_name = 'mlx4_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
                       ` (3 preceding siblings ...)
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 4/5] net/mlx: rename meson variable for dlopen option Thomas Monjalon
@ 2020-02-11  1:19     ` Thomas Monjalon
  2020-02-11 11:32       ` Bruce Richardson
  2020-02-11 11:33     ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking in meson Bruce Richardson
  5 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11  1:19 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, stable, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Nélio Laranjeiro

If ibverbs_link is dlopen, the PMD and application should not
be linked with ibverbs, but the glue library is.
Unfortunately the ibverbs dependency was exported in the
variable ext_deps, so there were overlinking.

It is fixed by not exporting the dependency in ext_deps,
and recreating a limited dependency object for cflags only.

Fixes: 1dd7c7e38c19 ("net/mlx4: support meson build")
Fixes: 96d7c62a70c7 ("net/mlx5: support meson build")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 6 ++++--
 drivers/net/mlx4/meson.build    | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 2bb2a83c45..2956fc20e2 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -30,7 +30,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -38,10 +38,12 @@ foreach libname:libnames
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
-if build and static_ibverbs
+if build and (static_ibverbs or dlopen_ibverbs)
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if build and static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 2970f395c1..bcfe5b0890 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -31,7 +31,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -39,10 +39,12 @@ foreach libname:libnames
 		reason = 'missing dependency, "' + libname + '"'
 	endif
 endforeach
-if build and static_ibverbs
+if build and (static_ibverbs or dlopen_ibverbs)
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if build and static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson Thomas Monjalon
@ 2020-02-11 11:29       ` Bruce Richardson
  2020-02-11 11:36         ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2020-02-11 11:29 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Tue, Feb 11, 2020 at 02:19:40AM +0100, Thomas Monjalon wrote:
> If ibverbs_link is static and the application choose to link DPDK
> as static libraries, both PMD and ibverbs libraries must be linked
> as static libraries. And the dependencies of ibverbs (netlink) must
> still be linked as shared libraries.
> 
> Unfortunately, meson forget about the static requirement for ibverbs
> when generating the .pc file.
> As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
> section (allowing to be linked as shared libraries) and libnl is missing.
> 
> 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
> 
> In order to avoid meson suggesting shared libraries in the section
> Requires.private of the .pc file, the dependency object is recreated
> with declare_dependency():
> 	- cflags are extracted the libibverbs.pc
> 	- ldflags, from libibverbs.pc, are processed to force
> 	static flavor of ibverbs libraries, thanks to this syntax:
> 			-l:libfoo.a
> 
> Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  buildtools/meson.build          |  2 ++
>  drivers/common/mlx5/meson.build | 12 +++++++++++-
>  drivers/net/mlx4/meson.build    | 14 ++++++++++++--
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index 0f563d89a3..4e3541b0d7 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -3,9 +3,11 @@
>  
>  subdir('pmdinfogen')
>  
> +pkgconf = find_program('pkg-config', 'pkgconf')
>  pmdinfo = find_program('gen-pmdinfo-cfile.sh')
>  list_dir_globs = find_program('list-dir-globs.py')
>  check_experimental_syms = find_program('check-experimental-syms.sh')
> +ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
>  
>  # set up map-to-def script using python, either built-in or external
>  python3 = import('python').find_installation(required: false)
> diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
> index f24e421bc3..bf04d16d76 100644
> --- a/drivers/common/mlx5/meson.build
> +++ b/drivers/common/mlx5/meson.build
> @@ -30,16 +30,26 @@ foreach libname:libnames
>  	endif
>  	if lib.found()
>  		libs += lib
> +		if not static_ibverbs
> +			ext_deps += lib
> +		endif
>  	else
>  		build = false
>  		reason = 'missing dependency, "' + libname + '"'
>  	endif
>  endforeach
> +if build and static_ibverbs
> +	# Build without adding shared libs to Requires.private
> +	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
> +	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
> +	# Add static deps ldflags to internal apps and Libs.private
> +	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
> +	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
> +endif
>  

Is there a reason for specfiying two dependencies, rather than putting both
cflags and ldflags into the one dependency object?


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
@ 2020-02-11 11:32       ` Bruce Richardson
  2020-02-11 11:34         ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Bruce Richardson @ 2020-02-11 11:32 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, stable, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Nélio Laranjeiro

On Tue, Feb 11, 2020 at 02:19:42AM +0100, Thomas Monjalon wrote:
> If ibverbs_link is dlopen, the PMD and application should not
> be linked with ibverbs, but the glue library is.
> Unfortunately the ibverbs dependency was exported in the
> variable ext_deps, so there were overlinking.
> 
> It is fixed by not exporting the dependency in ext_deps,
> and recreating a limited dependency object for cflags only.
> 
> Fixes: 1dd7c7e38c19 ("net/mlx4: support meson build")
> Fixes: 96d7c62a70c7 ("net/mlx5: support meson build")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/common/mlx5/meson.build | 6 ++++--
>  drivers/net/mlx4/meson.build    | 6 ++++--
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
> index 2bb2a83c45..2956fc20e2 100644
> --- a/drivers/common/mlx5/meson.build
> +++ b/drivers/common/mlx5/meson.build
> @@ -30,7 +30,7 @@ foreach libname:libnames
>  	endif
>  	if lib.found()
>  		libs += lib
> -		if not static_ibverbs
> +		if not static_ibverbs and not dlopen_ibverbs
>  			ext_deps += lib
>  		endif
>  	else
> @@ -38,10 +38,12 @@ foreach libname:libnames
>  		reason = 'missing dependency, "' + libname + '"'
>  	endif
>  endforeach
> -if build and static_ibverbs
> +if build and (static_ibverbs or dlopen_ibverbs)
>  	# Build without adding shared libs to Requires.private
>  	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
>  	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
> +endif
> +if build and static_ibverbs
>  	# Add static deps ldflags to internal apps and Libs.private
>  	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
>  	ext_deps += declare_dependency(link_args:ibv_ldflags.split())

One small suggestion:
Since out minimum version of meson is 0.47.1, we can use subdir_done()
function. Putting subdir_done() immediately after build=false will simplify
things as you won't need to continually check the build variable in each if
statement.

/Bruce

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking in meson
  2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
                       ` (4 preceding siblings ...)
  2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
@ 2020-02-11 11:33     ` Bruce Richardson
  5 siblings, 0 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-02-11 11:33 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Feb 11, 2020 at 02:19:37AM +0100, Thomas Monjalon wrote:
> This is the follow-up of the feature I added one year ago:
> static linkage of libibverbs in mlx PMDs.
> The first implementation was focused on "make".
> This second round does the same with "meson".
> 
> With the meson option ibverbs_link, only the mode "shared"
> was working correctly.
> This patchset adds the mode "static" and fixes the mode "dlopen".
> 
> 
> changes in v3:
> - get cflags with pkg-config invocation
> - drop addition of global variable hidden_deps
> - remove overlinking in dlopen mode
> 
> changes in v2:
> - split mlx patch for normal addition and workarounds
> - fix ldflags for ibverbs installed in a standard directory
> - fix libs order leading to undefined references
> - add doc for hidden_deps
> - improve explanations in commit logs
> 
> 
> Thomas Monjalon (5):
>   net/mlx: add static ibverbs linkage with meson
>   buildtools: get static mlx dependencies for meson
>   net/mlx: workaround static linkage with meson
>   net/mlx: rename meson variable for dlopen option
>   net/mlx: fix overlinking with meson and glue dlopen
> 
Send a couple of improvement suggestions for two of the patches, but
otherwise looks ok to me.

Series-acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen
  2020-02-11 11:32       ` Bruce Richardson
@ 2020-02-11 11:34         ` Thomas Monjalon
  0 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11 11:34 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, stable, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko,
	Nélio Laranjeiro

11/02/2020 12:32, Bruce Richardson:
> On Tue, Feb 11, 2020 at 02:19:42AM +0100, Thomas Monjalon wrote:
> > If ibverbs_link is dlopen, the PMD and application should not
> > be linked with ibverbs, but the glue library is.
> > Unfortunately the ibverbs dependency was exported in the
> > variable ext_deps, so there were overlinking.
> > 
> > It is fixed by not exporting the dependency in ext_deps,
> > and recreating a limited dependency object for cflags only.
> > 
> > Fixes: 1dd7c7e38c19 ("net/mlx4: support meson build")
> > Fixes: 96d7c62a70c7 ("net/mlx5: support meson build")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> >  drivers/common/mlx5/meson.build | 6 ++++--
> >  drivers/net/mlx4/meson.build    | 6 ++++--
> >  2 files changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
> > index 2bb2a83c45..2956fc20e2 100644
> > --- a/drivers/common/mlx5/meson.build
> > +++ b/drivers/common/mlx5/meson.build
> > @@ -30,7 +30,7 @@ foreach libname:libnames
> >  	endif
> >  	if lib.found()
> >  		libs += lib
> > -		if not static_ibverbs
> > +		if not static_ibverbs and not dlopen_ibverbs
> >  			ext_deps += lib
> >  		endif
> >  	else
> > @@ -38,10 +38,12 @@ foreach libname:libnames
> >  		reason = 'missing dependency, "' + libname + '"'
> >  	endif
> >  endforeach
> > -if build and static_ibverbs
> > +if build and (static_ibverbs or dlopen_ibverbs)
> >  	# Build without adding shared libs to Requires.private
> >  	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
> >  	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
> > +endif
> > +if build and static_ibverbs
> >  	# Add static deps ldflags to internal apps and Libs.private
> >  	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
> >  	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
> 
> One small suggestion:
> Since out minimum version of meson is 0.47.1, we can use subdir_done()
> function. Putting subdir_done() immediately after build=false will simplify
> things as you won't need to continually check the build variable in each if
> statement.

Great, thank you!




^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson
  2020-02-11 11:29       ` Bruce Richardson
@ 2020-02-11 11:36         ` Thomas Monjalon
  2020-02-11 11:43           ` Bruce Richardson
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-11 11:36 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

11/02/2020 12:29, Bruce Richardson:
> On Tue, Feb 11, 2020 at 02:19:40AM +0100, Thomas Monjalon wrote:
> > If ibverbs_link is static and the application choose to link DPDK
> > as static libraries, both PMD and ibverbs libraries must be linked
> > as static libraries. And the dependencies of ibverbs (netlink) must
> > still be linked as shared libraries.
> > 
> > Unfortunately, meson forget about the static requirement for ibverbs
> > when generating the .pc file.
> > As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
> > section (allowing to be linked as shared libraries) and libnl is missing.
> > 
> > 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
> > 
> > In order to avoid meson suggesting shared libraries in the section
> > Requires.private of the .pc file, the dependency object is recreated
> > with declare_dependency():
> > 	- cflags are extracted the libibverbs.pc
> > 	- ldflags, from libibverbs.pc, are processed to force
> > 	static flavor of ibverbs libraries, thanks to this syntax:
> > 			-l:libfoo.a
> > 
> > Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> > +if build and static_ibverbs
> > +	# Build without adding shared libs to Requires.private
> > +	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
> > +	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
> > +	# Add static deps ldflags to internal apps and Libs.private
> > +	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
> > +	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
> > +endif
> 
> Is there a reason for specfiying two dependencies, rather than putting both
> cflags and ldflags into the one dependency object?

Yes, the reason is the patch for dlopen which needs cflags only.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson
  2020-02-11 11:36         ` Thomas Monjalon
@ 2020-02-11 11:43           ` Bruce Richardson
  0 siblings, 0 replies; 59+ messages in thread
From: Bruce Richardson @ 2020-02-11 11:43 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

On Tue, Feb 11, 2020 at 12:36:06PM +0100, Thomas Monjalon wrote:
> 11/02/2020 12:29, Bruce Richardson:
> > On Tue, Feb 11, 2020 at 02:19:40AM +0100, Thomas Monjalon wrote:
> > > If ibverbs_link is static and the application choose to link DPDK
> > > as static libraries, both PMD and ibverbs libraries must be linked
> > > as static libraries. And the dependencies of ibverbs (netlink) must
> > > still be linked as shared libraries.
> > > 
> > > Unfortunately, meson forget about the static requirement for ibverbs
> > > when generating the .pc file.
> > > As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
> > > section (allowing to be linked as shared libraries) and libnl is missing.
> > > 
> > > 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
> > > 
> > > In order to avoid meson suggesting shared libraries in the section
> > > Requires.private of the .pc file, the dependency object is recreated
> > > with declare_dependency():
> > > 	- cflags are extracted the libibverbs.pc
> > > 	- ldflags, from libibverbs.pc, are processed to force
> > > 	static flavor of ibverbs libraries, thanks to this syntax:
> > > 			-l:libfoo.a
> > > 
> > > Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")
> > > 
> > > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > ---
> > > +if build and static_ibverbs
> > > +	# Build without adding shared libs to Requires.private
> > > +	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
> > > +	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
> > > +	# Add static deps ldflags to internal apps and Libs.private
> > > +	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
> > > +	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
> > > +endif
> > 
> > Is there a reason for specfiying two dependencies, rather than putting both
> > cflags and ldflags into the one dependency object?
> 
> Yes, the reason is the patch for dlopen which needs cflags only.
> 
Ah, ok, thanks for clarifying.

^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 0/6] mlx ibverbs linking in meson
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
                   ` (3 preceding siblings ...)
  2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
@ 2020-02-12  1:59 ` Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable Thomas Monjalon
                     ` (6 more replies)
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
  5 siblings, 7 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson

This is the follow-up of the feature I added one year ago:
static linkage of libibverbs in mlx PMDs.
The first implementation was focused on "make".
This second round does the same with "meson".

With the meson option ibverbs_link, only the mode "shared"
was working correctly.
This patchset adds the mode "static" and fixes the mode "dlopen".


changes in v4:
- fix lib ordering
- simplify conditions by using subdir_done()

changes in v3:
- get cflags with pkg-config invocation
- drop addition of global variable hidden_deps
- remove overlinking in dlopen mode

changes in v2:
- split mlx patch for normal addition and workarounds
- fix ldflags for ibverbs installed in a standard directory
- fix libs order leading to undefined references
- add doc for hidden_deps
- improve explanations in commit logs


Thomas Monjalon (6):
  drivers: cleanup meson build variable
  net/mlx: add static ibverbs linkage with meson
  buildtools: get static mlx dependencies for meson
  net/mlx: workaround static linkage with meson
  net/mlx: rename meson variable for dlopen option
  net/mlx: fix overlinking with meson and glue dlopen

 buildtools/meson.build               |   2 +
 buildtools/options-ibverbs-static.sh |  11 +-
 doc/guides/nics/mlx4.rst             |   4 +
 doc/guides/nics/mlx5.rst             |   4 +
 drivers/common/mlx5/meson.build      | 314 ++++++++++++++-------------
 drivers/net/ipn3ke/meson.build       |  17 +-
 drivers/net/mlx4/meson.build         | 154 +++++++------
 drivers/raw/ifpga/meson.build        |  23 +-
 meson_options.txt                    |   4 +-
 9 files changed, 286 insertions(+), 247 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  9:26     ` Xu, Rosen
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Rosen Xu, Tianfei zhang

The variable build is already initialized as true in
drivers/meson.build. Duplicate initializations can be removed from mlx.

When the variable build is set to false, it is easier to call
subdir_done() than branch the rest of the code on build condition.

Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 293 ++++++++++++++++----------------
 drivers/net/ipn3ke/meson.build  |  17 +-
 drivers/net/mlx4/meson.build    | 131 +++++++-------
 drivers/raw/ifpga/meson.build   |  23 ++-
 4 files changed, 230 insertions(+), 234 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 2b704107cd..be57558267 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -6,7 +6,6 @@ if not is_linux
 	reason = 'only supported on Linux'
 	subdir_done()
 endif
-build = true
 
 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
@@ -32,158 +31,158 @@ foreach libname:libnames
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
+		subdir_done()
 	endif
 endforeach
 
-if build
-	allow_experimental_apis = true
-	deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
-	ext_deps += libs
-	sources = files(
-		'mlx5_devx_cmds.c',
-		'mlx5_common.c',
-		'mlx5_nl.c',
-	)
-	if not pmd_dlopen
-		sources += files('mlx5_glue.c')
-	endif
-	cflags_options = [
-		'-std=c11',
-		'-Wno-strict-prototypes',
-		'-D_BSD_SOURCE',
-		'-D_DEFAULT_SOURCE',
-		'-D_XOPEN_SOURCE=600'
-	]
-	foreach option:cflags_options
-		if cc.has_argument(option)
-			cflags += option
-		endif
-	endforeach
-	if get_option('buildtype').contains('debug')
-		cflags += [ '-pedantic', '-DPEDANTIC' ]
-	else
-		cflags += [ '-UPEDANTIC' ]
+allow_experimental_apis = true
+deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
+ext_deps += libs
+sources = files(
+	'mlx5_devx_cmds.c',
+	'mlx5_common.c',
+	'mlx5_nl.c',
+)
+if not pmd_dlopen
+	sources += files('mlx5_glue.c')
+endif
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
 	endif
-	# To maintain the compatibility with the make build system
-	# mlx5_autoconf.h file is still generated.
-	# input array for meson member search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search", "struct member to search" ]
-	has_member_args = [
-		[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
-		'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
-		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
-		'struct ibv_counter_set_init_attr', 'counter_set_id' ],
-		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
-		'struct ibv_counters_init_attr', 'comp_mask' ],
-	]
-	# input array for meson symbol search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search" ]
-	has_sym_args = [
-		[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
-		'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
-		[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
-		[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
-		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
-		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
-		'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
-		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
-		'mlx5dv_create_flow_action_packet_reformat' ],
-		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
-		'IBV_FLOW_SPEC_MPLS' ],
-		[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
-		'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
-		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
-		'IBV_WQ_FLAG_RX_END_PADDING' ],
-		[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
-		'mlx5dv_query_devx_port' ],
-		[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_obj_create' ],
-		[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
-		'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
-		[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_obj_query_async' ],
-		[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_dest_devx_tir' ],
-		[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_get_event' ],
-		[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_flow_meter' ],
-		[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
-		'MLX5_MMAP_GET_NC_PAGES_CMD' ],
-		[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
-		'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
-		[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
-		'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
-		[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_push_vlan' ],
-		[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
-		[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseKR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseCR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseSR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseLR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseKR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseCR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseSR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseLR4_Full' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
-		[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
-		'IFLA_NUM_VF' ],
-		[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
-		'IFLA_EXT_MASK' ],
-		[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
-		'IFLA_PHYS_SWITCH_ID' ],
-		[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
-		'IFLA_PHYS_PORT_NAME' ],
-		[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
-		'RDMA_NL_NLDEV' ],
-		[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_CMD_GET' ],
-		[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_CMD_PORT_GET' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_DEV_INDEX' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_DEV_NAME' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_PORT_INDEX' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
-		[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
-		'mlx5dv_dump_dr_domain'],
-		[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-	]
-	config = configuration_data()
-	foreach arg:has_sym_args
-		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
-			dependencies: libs))
-	endforeach
-	foreach arg:has_member_args
-		file_prefix = '#include <' + arg[1] + '>'
-		config.set(arg[0], cc.has_member(arg[2], arg[3],
-			prefix : file_prefix, dependencies: libs))
-	endforeach
-	configure_file(output : 'mlx5_autoconf.h', configuration : config)
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
 endif
+# To maintain the compatibility with the make build system
+# mlx5_autoconf.h file is still generated.
+# input array for meson member search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search", "struct member to search" ]
+has_member_args = [
+	[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
+	'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
+	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
+	'struct ibv_counter_set_init_attr', 'counter_set_id' ],
+	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
+	'struct ibv_counters_init_attr', 'comp_mask' ],
+]
+# input array for meson symbol search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search" ]
+has_sym_args = [
+	[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
+	'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
+	[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
+	[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
+	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
+	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
+	'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
+	[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
+	'mlx5dv_create_flow_action_packet_reformat' ],
+	[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
+	'IBV_FLOW_SPEC_MPLS' ],
+	[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
+	'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
+	[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
+	'IBV_WQ_FLAG_RX_END_PADDING' ],
+	[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
+	'mlx5dv_query_devx_port' ],
+	[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_obj_create' ],
+	[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
+	'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
+	[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_obj_query_async' ],
+	[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_dest_devx_tir' ],
+	[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_get_event' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_flow_meter' ],
+	[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
+	'MLX5_MMAP_GET_NC_PAGES_CMD' ],
+	[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
+	'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
+	[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
+	'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
+	[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_push_vlan' ],
+	[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
+	[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseKR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseCR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseSR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseLR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseKR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseCR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseSR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseLR4_Full' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
+	[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
+	'IFLA_NUM_VF' ],
+	[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
+	'IFLA_EXT_MASK' ],
+	[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
+	'IFLA_PHYS_SWITCH_ID' ],
+	[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
+	'IFLA_PHYS_PORT_NAME' ],
+	[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
+	'RDMA_NL_NLDEV' ],
+	[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_CMD_GET' ],
+	[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_CMD_PORT_GET' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_DEV_INDEX' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_DEV_NAME' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_PORT_INDEX' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
+	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
+	'mlx5dv_dump_dr_domain'],
+	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
+]
+config = configuration_data()
+foreach arg:has_sym_args
+	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
+		dependencies: libs))
+endforeach
+foreach arg:has_member_args
+	file_prefix = '#include <' + arg[1] + '>'
+	config.set(arg[0], cc.has_member(arg[2], arg[3],
+		prefix : file_prefix, dependencies: libs))
+endforeach
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
+
 # Build Glue Library
-if pmd_dlopen and build
+if pmd_dlopen
 	dlopen_name = 'mlx5_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build
index bfec592aba..f19083af15 100644
--- a/drivers/net/ipn3ke/meson.build
+++ b/drivers/net/ipn3ke/meson.build
@@ -16,16 +16,15 @@ endif
 if not dep.found()
 	build = false
 	reason = 'missing dependency, "libfdt"'
+	subdir_done()
 endif
 
-if build
-	allow_experimental_apis = true
+allow_experimental_apis = true
 
-	includes += include_directories('../../raw/ifpga')
+includes += include_directories('../../raw/ifpga')
 
-	sources += files('ipn3ke_ethdev.c',
-		'ipn3ke_representor.c',
-		'ipn3ke_tm.c',
-		'ipn3ke_flow.c')
-	deps += ['bus_ifpga', 'ethdev', 'sched']
-endif
+sources += files('ipn3ke_ethdev.c',
+	'ipn3ke_representor.c',
+	'ipn3ke_tm.c',
+	'ipn3ke_flow.c')
+deps += ['bus_ifpga', 'ethdev', 'sched']
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 0260c5dc59..6d2397b3cc 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -7,7 +7,6 @@ if not is_linux
 	reason = 'only supported on Linux'
 	subdir_done()
 endif
-build = true
 
 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
@@ -33,77 +32,77 @@ foreach libname:libnames
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
+		subdir_done()
 	endif
 endforeach
 
-if build
-	allow_experimental_apis = true
-	ext_deps += libs
-	sources = files(
-		'mlx4.c',
-		'mlx4_ethdev.c',
-		'mlx4_flow.c',
-		'mlx4_intr.c',
-		'mlx4_mp.c',
-		'mlx4_mr.c',
-		'mlx4_rxq.c',
-		'mlx4_rxtx.c',
-		'mlx4_txq.c',
-		'mlx4_utils.c',
-	)
-	if not pmd_dlopen
-		sources += files('mlx4_glue.c')
-	endif
-	cflags_options = [
-		'-std=c11',
-		'-Wno-strict-prototypes',
-		'-D_BSD_SOURCE',
-		'-D_DEFAULT_SOURCE',
-		'-D_XOPEN_SOURCE=600'
-	]
-	foreach option:cflags_options
-		if cc.has_argument(option)
-			cflags += option
-		endif
-	endforeach
-	if get_option('buildtype').contains('debug')
-		cflags += [ '-pedantic', '-DPEDANTIC' ]
-	else
-		cflags += [ '-UPEDANTIC' ]
+allow_experimental_apis = true
+ext_deps += libs
+sources = files(
+	'mlx4.c',
+	'mlx4_ethdev.c',
+	'mlx4_flow.c',
+	'mlx4_intr.c',
+	'mlx4_mp.c',
+	'mlx4_mr.c',
+	'mlx4_rxq.c',
+	'mlx4_rxtx.c',
+	'mlx4_txq.c',
+	'mlx4_utils.c',
+)
+if not pmd_dlopen
+	sources += files('mlx4_glue.c')
+endif
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
 	endif
-	# To maintain the compatibility with the make build system
-	# mlx4_autoconf.h file is still generated.
-	# input array for meson member search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search", "struct member to search" ]
-	#
-	has_member_args = [
-		[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
-		'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
-	]
-	# input array for meson symbol search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search" ]
-	has_sym_args = [
-		[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
-		'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
-		[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
-		'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
-	]
-	config = configuration_data()
-	foreach arg:has_sym_args
-		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
-			dependencies: libs))
-	endforeach
-	foreach arg:has_member_args
-		file_prefix = '#include <' + arg[1] + '>'
-		config.set(arg[0], cc.has_member(arg[2], arg[3],
-			prefix: file_prefix, dependencies: libs))
-	endforeach
-	configure_file(output : 'mlx4_autoconf.h', configuration : config)
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
 endif
+# To maintain the compatibility with the make build system
+# mlx4_autoconf.h file is still generated.
+# input array for meson member search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search", "struct member to search" ]
+#
+has_member_args = [
+	[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
+	'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
+]
+# input array for meson symbol search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search" ]
+has_sym_args = [
+	[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
+	'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
+	[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
+	'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
+]
+config = configuration_data()
+foreach arg:has_sym_args
+	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
+		dependencies: libs))
+endforeach
+foreach arg:has_member_args
+	file_prefix = '#include <' + arg[1] + '>'
+	config.set(arg[0], cc.has_member(arg[2], arg[3],
+		prefix: file_prefix, dependencies: libs))
+endforeach
+configure_file(output : 'mlx4_autoconf.h', configuration : config)
+
 # Build Glue Library
-if pmd_dlopen and build
+if pmd_dlopen
 	dlopen_name = 'mlx4_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/raw/ifpga/meson.build b/drivers/raw/ifpga/meson.build
index d4027068d6..e2a4b8cccb 100644
--- a/drivers/raw/ifpga/meson.build
+++ b/drivers/raw/ifpga/meson.build
@@ -8,21 +8,20 @@ endif
 if not dep.found()
 	build = false
 	reason = 'missing dependency, "libfdt"'
+	subdir_done()
 endif
 
-if build
-	subdir('base')
-	objs = [base_objs]
+subdir('base')
+objs = [base_objs]
 
-	deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
-		'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
-	ext_deps += dep
+deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
+	'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
+ext_deps += dep
 
-	sources = files('ifpga_rawdev.c')
+sources = files('ifpga_rawdev.c')
 
-	includes += include_directories('base')
-	includes += include_directories('../../net/ipn3ke')
-	includes += include_directories('../../net/i40e')
+includes += include_directories('base')
+includes += include_directories('../../net/ipn3ke')
+includes += include_directories('../../net/i40e')
 
-	allow_experimental_apis = true
-endif
+allow_experimental_apis = true
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 2/6] net/mlx: add static ibverbs linkage with meson
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, John McNamara,
	Marko Kovacevic, Viacheslav Ovsiienko

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 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>
---
 doc/guides/nics/mlx4.rst        | 4 ++++
 doc/guides/nics/mlx5.rst        | 4 ++++
 drivers/common/mlx5/meson.build | 5 +++--
 drivers/net/mlx4/meson.build    | 5 +++--
 meson_options.txt               | 4 ++--
 5 files changed, 16 insertions(+), 6 deletions(-)

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 2411fb3461..ffab34d281 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -278,6 +278,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/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index be57558267..47ae1b65c2 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -7,6 +7,7 @@ if not is_linux
 	subdir_done()
 endif
 
+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 = '20.02.0'
@@ -22,8 +23,8 @@ 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()
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 6d2397b3cc..7513516764 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -8,6 +8,7 @@ if not is_linux
 	subdir_done()
 endif
 
+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'
@@ -23,8 +24,8 @@ 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()
diff --git a/meson_options.txt b/meson_options.txt
index 20be15fe6b..9e4923a4f1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -14,8 +14,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: '',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 3/6] buildtools: get static mlx dependencies for meson
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The shell script options-ibverbs-static.sh was used with make
in forcing static linkage of ibverbs libraries.

When choosing to link with a static dependency in meson,
the generated .pc file will not force such static linkage.
The solution will rely on using this script in meson.

If linking with libraries installed in a non-standard path,
an option -L is provided via EXTRA_LDFLAGS in case of using make.
With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
When statically linking an application, the .pc file must save the
-L path so the application link will work without any extra option.
That's why --libs-only-l is replaced with --libs which includes -L.
Options which are neither -l or -L are filtered out because not needed
and can cause compilation issues with the legacy system using make.

The other change in this script is to drop the first occurrences of the
main library file (libiverbs.a). Only the last occurrence is kept.
It fixes some undefined references when linking a static application
using libdpdk.pc.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 buildtools/options-ibverbs-static.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
index 0f285a343b..0740a711ff 100755
--- a/buildtools/options-ibverbs-static.sh
+++ b/buildtools/options-ibverbs-static.sh
@@ -9,6 +9,13 @@
 #
 # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
 
-pkg-config --libs-only-l --static libibverbs |
+lib='libibverbs'
+deps='pthread|nl'
+
+pkg-config --libs --static $lib |
 	tr '[:space:]' '\n' |
-	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
+	sed -n '/^-[Ll]/p' |   # extra link options may break with make
+	tac |
+	awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
+	tac
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 4/6] net/mlx: workaround static linkage with meson
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
                     ` (2 preceding siblings ...)
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

If ibverbs_link is static and the application choose to link DPDK
as static libraries, both PMD and ibverbs libraries must be linked
as static libraries. And the dependencies of ibverbs (netlink) must
still be linked as shared libraries.

Unfortunately, meson forget about the static requirement for ibverbs
when generating the .pc file.
As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
section (allowing to be linked as shared libraries) and libnl is missing.

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

In order to avoid meson suggesting shared libraries in the section
Requires.private of the .pc file, the dependency object is recreated
with declare_dependency():
	- cflags are extracted the libibverbs.pc
	- ldflags, from libibverbs.pc, are processed to force
	static flavor of ibverbs libraries, thanks to this syntax:
			-l:libfoo.a

Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/meson.build          |  2 ++
 drivers/common/mlx5/meson.build | 12 +++++++++++-
 drivers/net/mlx4/meson.build    | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index 0f563d89a3..4e3541b0d7 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -3,9 +3,11 @@
 
 subdir('pmdinfogen')
 
+pkgconf = find_program('pkg-config', 'pkgconf')
 pmdinfo = find_program('gen-pmdinfo-cfile.sh')
 list_dir_globs = find_program('list-dir-globs.py')
 check_experimental_syms = find_program('check-experimental-syms.sh')
+ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
 
 # set up map-to-def script using python, either built-in or external
 python3 = import('python').find_installation(required: false)
diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 47ae1b65c2..4e987ed277 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -29,16 +29,26 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 		subdir_done()
 	endif
 endforeach
+if static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 allow_experimental_apis = true
 deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
-ext_deps += libs
 sources = files(
 	'mlx5_devx_cmds.c',
 	'mlx5_common.c',
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 7513516764..290bd1e268 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -29,16 +29,26 @@ foreach libname:libnames
 		lib = cc.find_library(libname, required:false)
 	endif
 	if lib.found()
-		libs += [ lib ]
+		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 		subdir_done()
 	endif
 endforeach
+if static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 allow_experimental_apis = true
-ext_deps += libs
 sources = files(
 	'mlx4.c',
 	'mlx4_ethdev.c',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 5/6] net/mlx: rename meson variable for dlopen option
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
                     ` (3 preceding siblings ...)
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
  2020-02-12  2:08   ` [dpdk-dev] [PATCH v4 0/6] mlx ibverbs linking in meson Thomas Monjalon
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The name of the variable pmd_dlopen is confusing because
it can be understood as true if the PMD is dlopen,
whereas it means the ibverbs glue layer is a dlopen library.
That's why it is renamed dlopen_ibverbs.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 8 ++++----
 drivers/net/mlx4/meson.build    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 4e987ed277..0fe086136a 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -8,11 +8,11 @@ if not is_linux
 endif
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '20.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
@@ -54,7 +54,7 @@ sources = files(
 	'mlx5_common.c',
 	'mlx5_nl.c',
 )
-if not pmd_dlopen
+if not dlopen_ibverbs
 	sources += files('mlx5_glue.c')
 endif
 cflags_options = [
@@ -193,7 +193,7 @@ endforeach
 configure_file(output : 'mlx5_autoconf.h', configuration : config)
 
 # Build Glue Library
-if pmd_dlopen
+if dlopen_ibverbs
 	dlopen_name = 'mlx5_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 290bd1e268..f66e70f4d1 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -9,11 +9,11 @@ if not is_linux
 endif
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
@@ -61,7 +61,7 @@ sources = files(
 	'mlx4_txq.c',
 	'mlx4_utils.c',
 )
-if not pmd_dlopen
+if not dlopen_ibverbs
 	sources += files('mlx4_glue.c')
 endif
 cflags_options = [
@@ -113,7 +113,7 @@ endforeach
 configure_file(output : 'mlx4_autoconf.h', configuration : config)
 
 # Build Glue Library
-if pmd_dlopen
+if dlopen_ibverbs
 	dlopen_name = 'mlx4_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v4 6/6] net/mlx: fix overlinking with meson and glue dlopen
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
                     ` (4 preceding siblings ...)
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
@ 2020-02-12  1:59   ` Thomas Monjalon
  2020-02-12  2:08   ` [dpdk-dev] [PATCH v4 0/6] mlx ibverbs linking in meson Thomas Monjalon
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  1:59 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, stable, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Nélio Laranjeiro

If ibverbs_link is dlopen, the PMD and application should not
be linked with ibverbs, but the glue library is.
Unfortunately the ibverbs dependency was exported in the
variable ext_deps, so there were overlinking.

It is fixed by not exporting the dependency in ext_deps,
and recreating a limited dependency object for cflags only.

Fixes: 1dd7c7e38c19 ("net/mlx4: support meson build")
Fixes: 96d7c62a70c7 ("net/mlx5: support meson build")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 6 ++++--
 drivers/net/mlx4/meson.build    | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 0fe086136a..cfc178257d 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -29,7 +29,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -38,10 +38,12 @@ foreach libname:libnames
 		subdir_done()
 	endif
 endforeach
-if static_ibverbs
+if static_ibverbs or dlopen_ibverbs
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index f66e70f4d1..c598745730 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -30,7 +30,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -39,10 +39,12 @@ foreach libname:libnames
 		subdir_done()
 	endif
 endforeach
-if static_ibverbs
+if static_ibverbs or dlopen_ibverbs
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/6] mlx ibverbs linking in meson
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
                     ` (5 preceding siblings ...)
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
@ 2020-02-12  2:08   ` Thomas Monjalon
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  2:08 UTC (permalink / raw)
  To: dev, bruce.richardson

> Thomas Monjalon (6):
>   drivers: cleanup meson build variable
>   net/mlx: add static ibverbs linkage with meson
>   buildtools: get static mlx dependencies for meson
>   net/mlx: workaround static linkage with meson
>   net/mlx: rename meson variable for dlopen option
>   net/mlx: fix overlinking with meson and glue dlopen

Patches 2 to 6 were already Acked-by: Bruce Richardson <bruce.richardson@intel.com>



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable Thomas Monjalon
@ 2020-02-12  9:26     ` Xu, Rosen
  2020-02-12  9:32       ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Xu, Rosen @ 2020-02-12  9:26 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei

Hi,

I find some build error in patchwork.

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, February 12, 2020 10:00
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Matan Azrad
> <matan@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>;
> Viacheslav Ovsiienko <viacheslavo@mellanox.com>; Xu, Rosen
> <rosen.xu@intel.com>; Zhang, Tianfei <tianfei.zhang@intel.com>
> Subject: [PATCH v4 1/6] drivers: cleanup meson build variable
> 
> The variable build is already initialized as true in drivers/meson.build.
> Duplicate initializations can be removed from mlx.
> 
> When the variable build is set to false, it is easier to call
> subdir_done() than branch the rest of the code on build condition.
> 
> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/common/mlx5/meson.build | 293 ++++++++++++++++----------------
> drivers/net/ipn3ke/meson.build  |  17 +-
>  drivers/net/mlx4/meson.build    | 131 +++++++-------
>  drivers/raw/ifpga/meson.build   |  23 ++-
>  4 files changed, 230 insertions(+), 234 deletions(-)
> 
> diff --git a/drivers/common/mlx5/meson.build
> b/drivers/common/mlx5/meson.build index 2b704107cd..be57558267 100644
> --- a/drivers/common/mlx5/meson.build
> +++ b/drivers/common/mlx5/meson.build
> @@ -6,7 +6,6 @@ if not is_linux
>  	reason = 'only supported on Linux'
>  	subdir_done()
>  endif
> -build = true
> 
>  pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')  LIB_GLUE_BASE =
> 'librte_pmd_mlx5_glue.so'
> @@ -32,158 +31,158 @@ foreach libname:libnames
>  	else
>  		build = false
>  		reason = 'missing dependency, "' + libname + '"'
> +		subdir_done()
>  	endif
>  endforeach
> 
> -if build
> -	allow_experimental_apis = true
> -	deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
> -	ext_deps += libs
> -	sources = files(
> -		'mlx5_devx_cmds.c',
> -		'mlx5_common.c',
> -		'mlx5_nl.c',
> -	)
> -	if not pmd_dlopen
> -		sources += files('mlx5_glue.c')
> -	endif
> -	cflags_options = [
> -		'-std=c11',
> -		'-Wno-strict-prototypes',
> -		'-D_BSD_SOURCE',
> -		'-D_DEFAULT_SOURCE',
> -		'-D_XOPEN_SOURCE=600'
> -	]
> -	foreach option:cflags_options
> -		if cc.has_argument(option)
> -			cflags += option
> -		endif
> -	endforeach
> -	if get_option('buildtype').contains('debug')
> -		cflags += [ '-pedantic', '-DPEDANTIC' ]
> -	else
> -		cflags += [ '-UPEDANTIC' ]
> +allow_experimental_apis = true
> +deps += ['hash', 'pci', 'net', 'eal', 'kvargs'] ext_deps += libs
> +sources = files(
> +	'mlx5_devx_cmds.c',
> +	'mlx5_common.c',
> +	'mlx5_nl.c',
> +)
> +if not pmd_dlopen
> +	sources += files('mlx5_glue.c')
> +endif
> +cflags_options = [
> +	'-std=c11',
> +	'-Wno-strict-prototypes',
> +	'-D_BSD_SOURCE',
> +	'-D_DEFAULT_SOURCE',
> +	'-D_XOPEN_SOURCE=600'
> +]
> +foreach option:cflags_options
> +	if cc.has_argument(option)
> +		cflags += option
>  	endif
> -	# To maintain the compatibility with the make build system
> -	# mlx5_autoconf.h file is still generated.
> -	# input array for meson member search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search", "struct member to search" ]
> -	has_member_args = [
> -		[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
> -		'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
> -		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42',
> 'infiniband/verbs.h',
> -		'struct ibv_counter_set_init_attr', 'counter_set_id' ],
> -		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45',
> 'infiniband/verbs.h',
> -		'struct ibv_counters_init_attr', 'comp_mask' ],
> -	]
> -	# input array for meson symbol search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search" ]
> -	has_sym_args = [
> -		[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
> -		[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
> -		[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
> -		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
> -		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
> -		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_create_flow_action_packet_reformat' ],
> -		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
> -		'IBV_FLOW_SPEC_MPLS' ],
> -		[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING',
> 'infiniband/verbs.h',
> -		'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
> -		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING',
> 'infiniband/verbs.h',
> -		'IBV_WQ_FLAG_RX_END_PADDING' ],
> -		[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_query_devx_port' ],
> -		[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_obj_create' ],
> -		[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
> -		'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
> -		[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_obj_query_async' ],
> -		[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR',
> 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_dest_devx_tir' ],
> -		[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_get_event' ],
> -		[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER',
> 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_flow_meter' ],
> -		[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD',
> 'infiniband/mlx5dv.h',
> -		'MLX5_MMAP_GET_NC_PAGES_CMD' ],
> -		[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
> -		'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
> -		[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
> -		'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
> -		[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_push_vlan' ],
> -		[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
> -		[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseKR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseCR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseSR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseLR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseKR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseCR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseSR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseLR4_Full' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
> -		[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
> -		'IFLA_NUM_VF' ],
> -		[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
> -		'IFLA_EXT_MASK' ],
> -		[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
> -		'IFLA_PHYS_SWITCH_ID' ],
> -		[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
> -		'IFLA_PHYS_PORT_NAME' ],
> -		[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
> -		'RDMA_NL_NLDEV' ],
> -		[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_CMD_GET' ],
> -		[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_CMD_PORT_GET' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_DEV_INDEX' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_DEV_NAME' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_PORT_INDEX' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
> -		[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
> -		'mlx5dv_dump_dr_domain'],
> -		[ 'HAVE_DEVLINK', 'linux/devlink.h',
> 'DEVLINK_GENL_NAME' ],
> -	]
> -	config = configuration_data()
> -	foreach arg:has_sym_args
> -		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> -			dependencies: libs))
> -	endforeach
> -	foreach arg:has_member_args
> -		file_prefix = '#include <' + arg[1] + '>'
> -		config.set(arg[0], cc.has_member(arg[2], arg[3],
> -			prefix : file_prefix, dependencies: libs))
> -	endforeach
> -	configure_file(output : 'mlx5_autoconf.h', configuration : config)
> +endforeach
> +if get_option('buildtype').contains('debug')
> +	cflags += [ '-pedantic', '-DPEDANTIC' ] else
> +	cflags += [ '-UPEDANTIC' ]
>  endif
> +# To maintain the compatibility with the make build system #
> +mlx5_autoconf.h file is still generated.
> +# input array for meson member search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search", "struct member to search" ]
> +has_member_args = [
> +	[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
> +	'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
> +	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
> +	'struct ibv_counter_set_init_attr', 'counter_set_id' ],
> +	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
> +	'struct ibv_counters_init_attr', 'comp_mask' ], ] # input array for
> +meson symbol search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search" ]
> +has_sym_args = [
> +	[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT',
> 'infiniband/mlx5dv.h',
> +	'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
> +	[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
> +	[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
> +	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
> +	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
> +	[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_create_flow_action_packet_reformat' ],
> +	[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
> +	'IBV_FLOW_SPEC_MPLS' ],
> +	[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING',
> 'infiniband/verbs.h',
> +	'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
> +	[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
> +	'IBV_WQ_FLAG_RX_END_PADDING' ],
> +	[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_query_devx_port' ],
> +	[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_obj_create' ],
> +	[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
> +	'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
> +	[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_obj_query_async' ],
> +	[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_dest_devx_tir' ],
> +	[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_get_event' ],
> +	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_flow_meter' ],
> +	[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD',
> 'infiniband/mlx5dv.h',
> +	'MLX5_MMAP_GET_NC_PAGES_CMD' ],
> +	[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
> +	'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
> +	[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
> +	'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
> +	[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_push_vlan' ],
> +	[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
> +	[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseKR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseCR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseSR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseLR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseKR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseCR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseSR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseLR4_Full' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
> +	[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
> +	'IFLA_NUM_VF' ],
> +	[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
> +	'IFLA_EXT_MASK' ],
> +	[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
> +	'IFLA_PHYS_SWITCH_ID' ],
> +	[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
> +	'IFLA_PHYS_PORT_NAME' ],
> +	[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
> +	'RDMA_NL_NLDEV' ],
> +	[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_CMD_GET' ],
> +	[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_CMD_PORT_GET' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_DEV_INDEX' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_DEV_NAME' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_PORT_INDEX' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
> +	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
> +	'mlx5dv_dump_dr_domain'],
> +	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ], ]
> config =
> +configuration_data() foreach arg:has_sym_args
> +	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> +		dependencies: libs))
> +endforeach
> +foreach arg:has_member_args
> +	file_prefix = '#include <' + arg[1] + '>'
> +	config.set(arg[0], cc.has_member(arg[2], arg[3],
> +		prefix : file_prefix, dependencies: libs)) endforeach
> +configure_file(output : 'mlx5_autoconf.h', configuration : config)
> +
>  # Build Glue Library
> -if pmd_dlopen and build
> +if pmd_dlopen
>  	dlopen_name = 'mlx5_glue'
>  	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
>  	dlopen_so_version = LIB_GLUE_VERSION
> diff --git a/drivers/net/ipn3ke/meson.build
> b/drivers/net/ipn3ke/meson.build index bfec592aba..f19083af15 100644
> --- a/drivers/net/ipn3ke/meson.build
> +++ b/drivers/net/ipn3ke/meson.build
> @@ -16,16 +16,15 @@ endif
>  if not dep.found()
>  	build = false
>  	reason = 'missing dependency, "libfdt"'
> +	subdir_done()
>  endif
> 
> -if build
> -	allow_experimental_apis = true
> +allow_experimental_apis = true
> 
> -	includes += include_directories('../../raw/ifpga')
> +includes += include_directories('../../raw/ifpga')
> 
> -	sources += files('ipn3ke_ethdev.c',
> -		'ipn3ke_representor.c',
> -		'ipn3ke_tm.c',
> -		'ipn3ke_flow.c')
> -	deps += ['bus_ifpga', 'ethdev', 'sched']
> -endif
> +sources += files('ipn3ke_ethdev.c',
> +	'ipn3ke_representor.c',
> +	'ipn3ke_tm.c',
> +	'ipn3ke_flow.c')
> +deps += ['bus_ifpga', 'ethdev', 'sched']
> diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
> index 0260c5dc59..6d2397b3cc 100644
> --- a/drivers/net/mlx4/meson.build
> +++ b/drivers/net/mlx4/meson.build
> @@ -7,7 +7,6 @@ if not is_linux
>  	reason = 'only supported on Linux'
>  	subdir_done()
>  endif
> -build = true
> 
>  pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')  LIB_GLUE_BASE =
> 'librte_pmd_mlx4_glue.so'
> @@ -33,77 +32,77 @@ foreach libname:libnames
>  	else
>  		build = false
>  		reason = 'missing dependency, "' + libname + '"'
> +		subdir_done()
>  	endif
>  endforeach
> 
> -if build
> -	allow_experimental_apis = true
> -	ext_deps += libs
> -	sources = files(
> -		'mlx4.c',
> -		'mlx4_ethdev.c',
> -		'mlx4_flow.c',
> -		'mlx4_intr.c',
> -		'mlx4_mp.c',
> -		'mlx4_mr.c',
> -		'mlx4_rxq.c',
> -		'mlx4_rxtx.c',
> -		'mlx4_txq.c',
> -		'mlx4_utils.c',
> -	)
> -	if not pmd_dlopen
> -		sources += files('mlx4_glue.c')
> -	endif
> -	cflags_options = [
> -		'-std=c11',
> -		'-Wno-strict-prototypes',
> -		'-D_BSD_SOURCE',
> -		'-D_DEFAULT_SOURCE',
> -		'-D_XOPEN_SOURCE=600'
> -	]
> -	foreach option:cflags_options
> -		if cc.has_argument(option)
> -			cflags += option
> -		endif
> -	endforeach
> -	if get_option('buildtype').contains('debug')
> -		cflags += [ '-pedantic', '-DPEDANTIC' ]
> -	else
> -		cflags += [ '-UPEDANTIC' ]
> +allow_experimental_apis = true
> +ext_deps += libs
> +sources = files(
> +	'mlx4.c',
> +	'mlx4_ethdev.c',
> +	'mlx4_flow.c',
> +	'mlx4_intr.c',
> +	'mlx4_mp.c',
> +	'mlx4_mr.c',
> +	'mlx4_rxq.c',
> +	'mlx4_rxtx.c',
> +	'mlx4_txq.c',
> +	'mlx4_utils.c',
> +)
> +if not pmd_dlopen
> +	sources += files('mlx4_glue.c')
> +endif
> +cflags_options = [
> +	'-std=c11',
> +	'-Wno-strict-prototypes',
> +	'-D_BSD_SOURCE',
> +	'-D_DEFAULT_SOURCE',
> +	'-D_XOPEN_SOURCE=600'
> +]
> +foreach option:cflags_options
> +	if cc.has_argument(option)
> +		cflags += option
>  	endif
> -	# To maintain the compatibility with the make build system
> -	# mlx4_autoconf.h file is still generated.
> -	# input array for meson member search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search", "struct member to search" ]
> -	#
> -	has_member_args = [
> -		[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
> -		'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
> -	]
> -	# input array for meson symbol search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search" ]
> -	has_sym_args = [
> -		[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS',
> 'infiniband/mlx4dv.h',
> -		'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
> -		[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET',
> 'infiniband/mlx4dv.h',
> -		'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
> -	]
> -	config = configuration_data()
> -	foreach arg:has_sym_args
> -		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> -			dependencies: libs))
> -	endforeach
> -	foreach arg:has_member_args
> -		file_prefix = '#include <' + arg[1] + '>'
> -		config.set(arg[0], cc.has_member(arg[2], arg[3],
> -			prefix: file_prefix, dependencies: libs))
> -	endforeach
> -	configure_file(output : 'mlx4_autoconf.h', configuration : config)
> +endforeach
> +if get_option('buildtype').contains('debug')
> +	cflags += [ '-pedantic', '-DPEDANTIC' ] else
> +	cflags += [ '-UPEDANTIC' ]
>  endif
> +# To maintain the compatibility with the make build system #
> +mlx4_autoconf.h file is still generated.
> +# input array for meson member search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search", "struct member to search" ]
> +#
> +has_member_args = [
> +	[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
> +	'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ], ] # input array for
> meson
> +symbol search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search" ]
> +has_sym_args = [
> +	[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
> +	'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
> +	[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
> +	'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
> +]
> +config = configuration_data()
> +foreach arg:has_sym_args
> +	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> +		dependencies: libs))
> +endforeach
> +foreach arg:has_member_args
> +	file_prefix = '#include <' + arg[1] + '>'
> +	config.set(arg[0], cc.has_member(arg[2], arg[3],
> +		prefix: file_prefix, dependencies: libs)) endforeach
> +configure_file(output : 'mlx4_autoconf.h', configuration : config)
> +
>  # Build Glue Library
> -if pmd_dlopen and build
> +if pmd_dlopen
>  	dlopen_name = 'mlx4_glue'
>  	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
>  	dlopen_so_version = LIB_GLUE_VERSION
> diff --git a/drivers/raw/ifpga/meson.build b/drivers/raw/ifpga/meson.build
> index d4027068d6..e2a4b8cccb 100644
> --- a/drivers/raw/ifpga/meson.build
> +++ b/drivers/raw/ifpga/meson.build
> @@ -8,21 +8,20 @@ endif
>  if not dep.found()
>  	build = false
>  	reason = 'missing dependency, "libfdt"'
> +	subdir_done()
>  endif
> 
> -if build
> -	subdir('base')
> -	objs = [base_objs]
> +subdir('base')
> +objs = [base_objs]
> 
> -	deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
> -		'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
> -	ext_deps += dep
> +deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
> +	'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke'] ext_deps +=
> +dep
> 
> -	sources = files('ifpga_rawdev.c')
> +sources = files('ifpga_rawdev.c')
> 
> -	includes += include_directories('base')
> -	includes += include_directories('../../net/ipn3ke')
> -	includes += include_directories('../../net/i40e')
> +includes += include_directories('base') includes +=
> +include_directories('../../net/ipn3ke')
> +includes += include_directories('../../net/i40e')
> 
> -	allow_experimental_apis = true
> -endif
> +allow_experimental_apis = true
> --
> 2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12  9:26     ` Xu, Rosen
@ 2020-02-12  9:32       ` Thomas Monjalon
  2020-02-12 15:04         ` [dpdk-dev] [dpdklab] " Jeremy Plsek
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12  9:32 UTC (permalink / raw)
  To: Xu, Rosen
  Cc: dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

12/02/2020 10:26, Xu, Rosen:
> I find some build error in patchwork.

This is a failure in the unit tests, probably unrelated:
	https://lab.dpdk.org/results/dashboard/patchsets/9573/

This is the error message:
	buildtools/meson.build:6:0: ERROR:
	Program(s) ['pkg-config', 'pkgconf'] not found or not executable

I think we can ignore, this is clearly an issue in the setup.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12  9:32       ` Thomas Monjalon
@ 2020-02-12 15:04         ` Jeremy Plsek
  2020-02-12 15:18           ` Jeremy Plsek
  0 siblings, 1 reply; 59+ messages in thread
From: Jeremy Plsek @ 2020-02-12 15:04 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 12/02/2020 10:26, Xu, Rosen:
> > I find some build error in patchwork.
>
> This is a failure in the unit tests, probably unrelated:
>         https://lab.dpdk.org/results/dashboard/patchsets/9573/
>
> This is the error message:
>         buildtools/meson.build:6:0: ERROR:
>         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
>
> I think we can ignore, this is clearly an issue in the setup.
>
>
The windows guide does not mention needing pkgconfig to build dpdk on
windows. The guide should be updated if this is the case.
https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 15:04         ` [dpdk-dev] [dpdklab] " Jeremy Plsek
@ 2020-02-12 15:18           ` Jeremy Plsek
  2020-02-12 16:30             ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Jeremy Plsek @ 2020-02-12 15:18 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
>
> On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 12/02/2020 10:26, Xu, Rosen:
> > > I find some build error in patchwork.
> >
> > This is a failure in the unit tests, probably unrelated:
> >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> >
> > This is the error message:
> >         buildtools/meson.build:6:0: ERROR:
> >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> >
> > I think we can ignore, this is clearly an issue in the setup.
> >
> >
> The windows guide does not mention needing pkgconfig to build dpdk on
> windows. The guide should be updated if this is the case.
> https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html

As an update, installing pkgconfiglite does make the build pass.

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 15:18           ` Jeremy Plsek
@ 2020-02-12 16:30             ` Thomas Monjalon
  2020-02-12 16:36               ` Jeremy Plsek
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 16:30 UTC (permalink / raw)
  To: Jeremy Plsek
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

12/02/2020 16:18, Jeremy Plsek:
> On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> >
> > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > 12/02/2020 10:26, Xu, Rosen:
> > > > I find some build error in patchwork.
> > >
> > > This is a failure in the unit tests, probably unrelated:
> > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > >
> > > This is the error message:
> > >         buildtools/meson.build:6:0: ERROR:
> > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > >
> > > I think we can ignore, this is clearly an issue in the setup.
> > >
> > >
> > The windows guide does not mention needing pkgconfig to build dpdk on
> > windows. The guide should be updated if this is the case.
> > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> 
> As an update, installing pkgconfiglite does make the build pass.

I don't understand Jeremy; the issue is seen in Ubuntu.
Please check the link above.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 16:30             ` Thomas Monjalon
@ 2020-02-12 16:36               ` Jeremy Plsek
  2020-02-12 16:42                 ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Jeremy Plsek @ 2020-02-12 16:36 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

On Wed, Feb 12, 2020 at 11:30 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 12/02/2020 16:18, Jeremy Plsek:
> > On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> > >
> > > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > >
> > > > 12/02/2020 10:26, Xu, Rosen:
> > > > > I find some build error in patchwork.
> > > >
> > > > This is a failure in the unit tests, probably unrelated:
> > > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > > >
> > > > This is the error message:
> > > >         buildtools/meson.build:6:0: ERROR:
> > > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > > >
> > > > I think we can ignore, this is clearly an issue in the setup.
> > > >
> > > >
> > > The windows guide does not mention needing pkgconfig to build dpdk on
> > > windows. The guide should be updated if this is the case.
> > > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> >
> > As an update, installing pkgconfiglite does make the build pass.
>
> I don't understand Jeremy; the issue is seen in Ubuntu.
> Please check the link above.
>
>
Oh, I only looked at the windows build fail, not the unit tests.
Apparently they both had the same issue. I will fix the unit test
system.

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 16:36               ` Jeremy Plsek
@ 2020-02-12 16:42                 ` Thomas Monjalon
  2020-02-12 16:46                   ` Jeremy Plsek
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 16:42 UTC (permalink / raw)
  To: Jeremy Plsek
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

12/02/2020 17:36, Jeremy Plsek:
> On Wed, Feb 12, 2020 at 11:30 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 12/02/2020 16:18, Jeremy Plsek:
> > > On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> > > >
> > > > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > > >
> > > > > 12/02/2020 10:26, Xu, Rosen:
> > > > > > I find some build error in patchwork.
> > > > >
> > > > > This is a failure in the unit tests, probably unrelated:
> > > > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > > > >
> > > > > This is the error message:
> > > > >         buildtools/meson.build:6:0: ERROR:
> > > > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > > > >
> > > > > I think we can ignore, this is clearly an issue in the setup.
> > > > >
> > > > >
> > > > The windows guide does not mention needing pkgconfig to build dpdk on
> > > > windows. The guide should be updated if this is the case.
> > > > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> > >
> > > As an update, installing pkgconfiglite does make the build pass.
> >
> > I don't understand Jeremy; the issue is seen in Ubuntu.
> > Please check the link above.
> >
> >
> Oh, I only looked at the windows build fail, not the unit tests.
> Apparently they both had the same issue. I will fix the unit test
> system.

Please could you show where is the error on Windows?
There is maybe something to fix here.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 16:42                 ` Thomas Monjalon
@ 2020-02-12 16:46                   ` Jeremy Plsek
  2020-02-12 17:38                     ` Thomas Monjalon
  0 siblings, 1 reply; 59+ messages in thread
From: Jeremy Plsek @ 2020-02-12 16:46 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

On Wed, Feb 12, 2020 at 11:42 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 12/02/2020 17:36, Jeremy Plsek:
> > On Wed, Feb 12, 2020 at 11:30 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > 12/02/2020 16:18, Jeremy Plsek:
> > > > On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> > > > >
> > > > > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > > > >
> > > > > > 12/02/2020 10:26, Xu, Rosen:
> > > > > > > I find some build error in patchwork.
> > > > > >
> > > > > > This is a failure in the unit tests, probably unrelated:
> > > > > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > > > > >
> > > > > > This is the error message:
> > > > > >         buildtools/meson.build:6:0: ERROR:
> > > > > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > > > > >
> > > > > > I think we can ignore, this is clearly an issue in the setup.
> > > > > >
> > > > > >
> > > > > The windows guide does not mention needing pkgconfig to build dpdk on
> > > > > windows. The guide should be updated if this is the case.
> > > > > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> > > >
> > > > As an update, installing pkgconfiglite does make the build pass.
> > >
> > > I don't understand Jeremy; the issue is seen in Ubuntu.
> > > Please check the link above.
> > >
> > >
> > Oh, I only looked at the windows build fail, not the unit tests.
> > Apparently they both had the same issue. I will fix the unit test
> > system.
>
> Please could you show where is the error on Windows?
> There is maybe something to fix here.
>
>
See "Run 1" under:
https://lab.dpdk.org/results/dashboard/patchsets/9573/#env-27
Direct download:
https://lab.dpdk.org/results/dashboard/results/results-uploads/test_runs/74f515cb64bd47f698cc2290ebaea571/log_upload_file/2020/2/dpdk_43e34a229d3e_9573_2020-02-12_03-00-39_NA.zip

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 16:46                   ` Jeremy Plsek
@ 2020-02-12 17:38                     ` Thomas Monjalon
  2020-02-12 18:03                       ` Jeremy Plsek
  0 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 17:38 UTC (permalink / raw)
  To: Jeremy Plsek
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

12/02/2020 17:46, Jeremy Plsek:
> On Wed, Feb 12, 2020 at 11:42 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > 12/02/2020 17:36, Jeremy Plsek:
> > > On Wed, Feb 12, 2020 at 11:30 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > >
> > > > 12/02/2020 16:18, Jeremy Plsek:
> > > > > On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> > > > > >
> > > > > > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > > > > >
> > > > > > > 12/02/2020 10:26, Xu, Rosen:
> > > > > > > > I find some build error in patchwork.
> > > > > > >
> > > > > > > This is a failure in the unit tests, probably unrelated:
> > > > > > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > > > > > >
> > > > > > > This is the error message:
> > > > > > >         buildtools/meson.build:6:0: ERROR:
> > > > > > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > > > > > >
> > > > > > > I think we can ignore, this is clearly an issue in the setup.
> > > > > > >
> > > > > > >
> > > > > > The windows guide does not mention needing pkgconfig to build dpdk on
> > > > > > windows. The guide should be updated if this is the case.
> > > > > > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> > > > >
> > > > > As an update, installing pkgconfiglite does make the build pass.
> > > >
> > > > I don't understand Jeremy; the issue is seen in Ubuntu.
> > > > Please check the link above.
> > > >
> > > >
> > > Oh, I only looked at the windows build fail, not the unit tests.
> > > Apparently they both had the same issue. I will fix the unit test
> > > system.
> >
> > Please could you show where is the error on Windows?
> > There is maybe something to fix here.
> >
> >
> See "Run 1" under:
> https://lab.dpdk.org/results/dashboard/patchsets/9573/#env-27
> Direct download:
> https://lab.dpdk.org/results/dashboard/results/results-uploads/test_runs/74f515cb64bd47f698cc2290ebaea571/log_upload_file/2020/2/dpdk_43e34a229d3e_9573_2020-02-12_03-00-39_NA.zip

I see, thanks

If pkg-config is not required so far, please do not intall it.
I will fix this patch for Windows.



^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [dpdklab] Re: [PATCH v4 1/6] drivers: cleanup meson build variable
  2020-02-12 17:38                     ` Thomas Monjalon
@ 2020-02-12 18:03                       ` Jeremy Plsek
  0 siblings, 0 replies; 59+ messages in thread
From: Jeremy Plsek @ 2020-02-12 18:03 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Xu, Rosen, dev, Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei, dpdklab

On Wed, Feb 12, 2020 at 12:38 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 12/02/2020 17:46, Jeremy Plsek:
> > On Wed, Feb 12, 2020 at 11:42 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > >
> > > 12/02/2020 17:36, Jeremy Plsek:
> > > > On Wed, Feb 12, 2020 at 11:30 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > > >
> > > > > 12/02/2020 16:18, Jeremy Plsek:
> > > > > > On Wed, Feb 12, 2020 at 10:04 AM Jeremy Plsek <jplsek@iol.unh.edu> wrote:
> > > > > > >
> > > > > > > On Wed, Feb 12, 2020 at 4:32 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > > > > > >
> > > > > > > > 12/02/2020 10:26, Xu, Rosen:
> > > > > > > > > I find some build error in patchwork.
> > > > > > > >
> > > > > > > > This is a failure in the unit tests, probably unrelated:
> > > > > > > >         https://lab.dpdk.org/results/dashboard/patchsets/9573/
> > > > > > > >
> > > > > > > > This is the error message:
> > > > > > > >         buildtools/meson.build:6:0: ERROR:
> > > > > > > >         Program(s) ['pkg-config', 'pkgconf'] not found or not executable
> > > > > > > >
> > > > > > > > I think we can ignore, this is clearly an issue in the setup.
> > > > > > > >
> > > > > > > >
> > > > > > > The windows guide does not mention needing pkgconfig to build dpdk on
> > > > > > > windows. The guide should be updated if this is the case.
> > > > > > > https://doc.dpdk.org/guides/windows_gsg/build_dpdk.html
> > > > > >
> > > > > > As an update, installing pkgconfiglite does make the build pass.
> > > > >
> > > > > I don't understand Jeremy; the issue is seen in Ubuntu.
> > > > > Please check the link above.
> > > > >
> > > > >
> > > > Oh, I only looked at the windows build fail, not the unit tests.
> > > > Apparently they both had the same issue. I will fix the unit test
> > > > system.
> > >
> > > Please could you show where is the error on Windows?
> > > There is maybe something to fix here.
> > >
> > >
> > See "Run 1" under:
> > https://lab.dpdk.org/results/dashboard/patchsets/9573/#env-27
> > Direct download:
> > https://lab.dpdk.org/results/dashboard/results/results-uploads/test_runs/74f515cb64bd47f698cc2290ebaea571/log_upload_file/2020/2/dpdk_43e34a229d3e_9573_2020-02-12_03-00-39_NA.zip
>
> I see, thanks
>
> If pkg-config is not required so far, please do not intall it.
> I will fix this patch for Windows.
>
>
Ok, I've removed pkg-config from the windows build server.

^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson
  2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
                   ` (4 preceding siblings ...)
  2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
@ 2020-02-12 22:07 ` Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable Thomas Monjalon
                     ` (6 more replies)
  5 siblings, 7 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson

This is the follow-up of the feature I added one year ago:
static linkage of libibverbs in mlx PMDs.
The first implementation was focused on "make".
This second round does the same with "meson".

With the meson option ibverbs_link, only the mode "shared"
was working correctly.
This patchset adds the mode "static" and fixes the mode "dlopen".


changes in v5:
- fix build if pkg-config/pkgconf is missing (e.g. Windows)

changes in v4:
- fix lib ordering
- simplify conditions by using subdir_done()

changes in v3:
- get cflags with pkg-config invocation
- drop addition of global variable hidden_deps
- remove overlinking in dlopen mode

changes in v2:
- split mlx patch for normal addition and workarounds
- fix ldflags for ibverbs installed in a standard directory
- fix libs order leading to undefined references
- add doc for hidden_deps
- improve explanations in commit logs


Thomas Monjalon (6):
  drivers: cleanup meson build variable
  net/mlx: add static ibverbs linkage with meson
  buildtools: get static mlx dependencies for meson
  net/mlx: workaround static linkage with meson
  net/mlx: rename meson variable for dlopen option
  net/mlx: fix overlinking with meson and glue dlopen

 buildtools/meson.build               |   2 +
 buildtools/options-ibverbs-static.sh |  11 +-
 doc/guides/nics/mlx4.rst             |   4 +
 doc/guides/nics/mlx5.rst             |   4 +
 drivers/common/mlx5/meson.build      | 314 ++++++++++++++-------------
 drivers/net/ipn3ke/meson.build       |  17 +-
 drivers/net/mlx4/meson.build         | 154 +++++++------
 drivers/raw/ifpga/meson.build        |  23 +-
 meson_options.txt                    |   4 +-
 9 files changed, 286 insertions(+), 247 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-13  0:25     ` Xu, Rosen
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Rosen Xu, Tianfei zhang

The variable build is already initialized as true in
drivers/meson.build. Duplicate initializations can be removed from mlx.

When the variable build is set to false, it is easier to call
subdir_done() than branch the rest of the code on build condition.

Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/common/mlx5/meson.build | 293 ++++++++++++++++----------------
 drivers/net/ipn3ke/meson.build  |  17 +-
 drivers/net/mlx4/meson.build    | 131 +++++++-------
 drivers/raw/ifpga/meson.build   |  23 ++-
 4 files changed, 230 insertions(+), 234 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 2b704107cd..be57558267 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -6,7 +6,6 @@ if not is_linux
 	reason = 'only supported on Linux'
 	subdir_done()
 endif
-build = true
 
 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
@@ -32,158 +31,158 @@ foreach libname:libnames
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
+		subdir_done()
 	endif
 endforeach
 
-if build
-	allow_experimental_apis = true
-	deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
-	ext_deps += libs
-	sources = files(
-		'mlx5_devx_cmds.c',
-		'mlx5_common.c',
-		'mlx5_nl.c',
-	)
-	if not pmd_dlopen
-		sources += files('mlx5_glue.c')
-	endif
-	cflags_options = [
-		'-std=c11',
-		'-Wno-strict-prototypes',
-		'-D_BSD_SOURCE',
-		'-D_DEFAULT_SOURCE',
-		'-D_XOPEN_SOURCE=600'
-	]
-	foreach option:cflags_options
-		if cc.has_argument(option)
-			cflags += option
-		endif
-	endforeach
-	if get_option('buildtype').contains('debug')
-		cflags += [ '-pedantic', '-DPEDANTIC' ]
-	else
-		cflags += [ '-UPEDANTIC' ]
+allow_experimental_apis = true
+deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
+ext_deps += libs
+sources = files(
+	'mlx5_devx_cmds.c',
+	'mlx5_common.c',
+	'mlx5_nl.c',
+)
+if not pmd_dlopen
+	sources += files('mlx5_glue.c')
+endif
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
 	endif
-	# To maintain the compatibility with the make build system
-	# mlx5_autoconf.h file is still generated.
-	# input array for meson member search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search", "struct member to search" ]
-	has_member_args = [
-		[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
-		'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
-		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
-		'struct ibv_counter_set_init_attr', 'counter_set_id' ],
-		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
-		'struct ibv_counters_init_attr', 'comp_mask' ],
-	]
-	# input array for meson symbol search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search" ]
-	has_sym_args = [
-		[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
-		'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
-		[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
-		[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
-		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
-		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
-		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
-		'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
-		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
-		'mlx5dv_create_flow_action_packet_reformat' ],
-		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
-		'IBV_FLOW_SPEC_MPLS' ],
-		[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
-		'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
-		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
-		'IBV_WQ_FLAG_RX_END_PADDING' ],
-		[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
-		'mlx5dv_query_devx_port' ],
-		[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_obj_create' ],
-		[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
-		'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
-		[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_obj_query_async' ],
-		[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_dest_devx_tir' ],
-		[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
-		'mlx5dv_devx_get_event' ],
-		[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_flow_meter' ],
-		[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
-		'MLX5_MMAP_GET_NC_PAGES_CMD' ],
-		[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
-		'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
-		[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
-		'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
-		[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
-		'mlx5dv_dr_action_create_push_vlan' ],
-		[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
-		[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseKR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseCR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseSR4_Full' ],
-		[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_40000baseLR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseKR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseCR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseSR4_Full' ],
-		[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
-		'SUPPORTED_56000baseLR4_Full' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
-		[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
-		'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
-		[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
-		'IFLA_NUM_VF' ],
-		[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
-		'IFLA_EXT_MASK' ],
-		[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
-		'IFLA_PHYS_SWITCH_ID' ],
-		[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
-		'IFLA_PHYS_PORT_NAME' ],
-		[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
-		'RDMA_NL_NLDEV' ],
-		[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_CMD_GET' ],
-		[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_CMD_PORT_GET' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_DEV_INDEX' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_DEV_NAME' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_PORT_INDEX' ],
-		[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
-		'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
-		[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
-		'mlx5dv_dump_dr_domain'],
-		[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-	]
-	config = configuration_data()
-	foreach arg:has_sym_args
-		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
-			dependencies: libs))
-	endforeach
-	foreach arg:has_member_args
-		file_prefix = '#include <' + arg[1] + '>'
-		config.set(arg[0], cc.has_member(arg[2], arg[3],
-			prefix : file_prefix, dependencies: libs))
-	endforeach
-	configure_file(output : 'mlx5_autoconf.h', configuration : config)
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
 endif
+# To maintain the compatibility with the make build system
+# mlx5_autoconf.h file is still generated.
+# input array for meson member search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search", "struct member to search" ]
+has_member_args = [
+	[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
+	'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
+	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
+	'struct ibv_counter_set_init_attr', 'counter_set_id' ],
+	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
+	'struct ibv_counters_init_attr', 'comp_mask' ],
+]
+# input array for meson symbol search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search" ]
+has_sym_args = [
+	[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT', 'infiniband/mlx5dv.h',
+	'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
+	[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
+	[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
+	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
+	'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
+	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
+	'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
+	[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
+	'mlx5dv_create_flow_action_packet_reformat' ],
+	[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
+	'IBV_FLOW_SPEC_MPLS' ],
+	[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING', 'infiniband/verbs.h',
+	'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
+	[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
+	'IBV_WQ_FLAG_RX_END_PADDING' ],
+	[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
+	'mlx5dv_query_devx_port' ],
+	[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_obj_create' ],
+	[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
+	'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
+	[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_obj_query_async' ],
+	[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_dest_devx_tir' ],
+	[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
+	'mlx5dv_devx_get_event' ],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_flow_meter' ],
+	[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
+	'MLX5_MMAP_GET_NC_PAGES_CMD' ],
+	[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
+	'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
+	[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
+	'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
+	[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_push_vlan' ],
+	[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
+	[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseKR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseCR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseSR4_Full' ],
+	[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_40000baseLR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseKR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseCR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseSR4_Full' ],
+	[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
+	'SUPPORTED_56000baseLR4_Full' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
+	[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
+	'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
+	[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
+	'IFLA_NUM_VF' ],
+	[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
+	'IFLA_EXT_MASK' ],
+	[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
+	'IFLA_PHYS_SWITCH_ID' ],
+	[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
+	'IFLA_PHYS_PORT_NAME' ],
+	[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
+	'RDMA_NL_NLDEV' ],
+	[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_CMD_GET' ],
+	[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_CMD_PORT_GET' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_DEV_INDEX' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_DEV_NAME' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_PORT_INDEX' ],
+	[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
+	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
+	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
+	'mlx5dv_dump_dr_domain'],
+	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
+]
+config = configuration_data()
+foreach arg:has_sym_args
+	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
+		dependencies: libs))
+endforeach
+foreach arg:has_member_args
+	file_prefix = '#include <' + arg[1] + '>'
+	config.set(arg[0], cc.has_member(arg[2], arg[3],
+		prefix : file_prefix, dependencies: libs))
+endforeach
+configure_file(output : 'mlx5_autoconf.h', configuration : config)
+
 # Build Glue Library
-if pmd_dlopen and build
+if pmd_dlopen
 	dlopen_name = 'mlx5_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/net/ipn3ke/meson.build b/drivers/net/ipn3ke/meson.build
index bfec592aba..f19083af15 100644
--- a/drivers/net/ipn3ke/meson.build
+++ b/drivers/net/ipn3ke/meson.build
@@ -16,16 +16,15 @@ endif
 if not dep.found()
 	build = false
 	reason = 'missing dependency, "libfdt"'
+	subdir_done()
 endif
 
-if build
-	allow_experimental_apis = true
+allow_experimental_apis = true
 
-	includes += include_directories('../../raw/ifpga')
+includes += include_directories('../../raw/ifpga')
 
-	sources += files('ipn3ke_ethdev.c',
-		'ipn3ke_representor.c',
-		'ipn3ke_tm.c',
-		'ipn3ke_flow.c')
-	deps += ['bus_ifpga', 'ethdev', 'sched']
-endif
+sources += files('ipn3ke_ethdev.c',
+	'ipn3ke_representor.c',
+	'ipn3ke_tm.c',
+	'ipn3ke_flow.c')
+deps += ['bus_ifpga', 'ethdev', 'sched']
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 0260c5dc59..6d2397b3cc 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -7,7 +7,6 @@ if not is_linux
 	reason = 'only supported on Linux'
 	subdir_done()
 endif
-build = true
 
 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
@@ -33,77 +32,77 @@ foreach libname:libnames
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
+		subdir_done()
 	endif
 endforeach
 
-if build
-	allow_experimental_apis = true
-	ext_deps += libs
-	sources = files(
-		'mlx4.c',
-		'mlx4_ethdev.c',
-		'mlx4_flow.c',
-		'mlx4_intr.c',
-		'mlx4_mp.c',
-		'mlx4_mr.c',
-		'mlx4_rxq.c',
-		'mlx4_rxtx.c',
-		'mlx4_txq.c',
-		'mlx4_utils.c',
-	)
-	if not pmd_dlopen
-		sources += files('mlx4_glue.c')
-	endif
-	cflags_options = [
-		'-std=c11',
-		'-Wno-strict-prototypes',
-		'-D_BSD_SOURCE',
-		'-D_DEFAULT_SOURCE',
-		'-D_XOPEN_SOURCE=600'
-	]
-	foreach option:cflags_options
-		if cc.has_argument(option)
-			cflags += option
-		endif
-	endforeach
-	if get_option('buildtype').contains('debug')
-		cflags += [ '-pedantic', '-DPEDANTIC' ]
-	else
-		cflags += [ '-UPEDANTIC' ]
+allow_experimental_apis = true
+ext_deps += libs
+sources = files(
+	'mlx4.c',
+	'mlx4_ethdev.c',
+	'mlx4_flow.c',
+	'mlx4_intr.c',
+	'mlx4_mp.c',
+	'mlx4_mr.c',
+	'mlx4_rxq.c',
+	'mlx4_rxtx.c',
+	'mlx4_txq.c',
+	'mlx4_utils.c',
+)
+if not pmd_dlopen
+	sources += files('mlx4_glue.c')
+endif
+cflags_options = [
+	'-std=c11',
+	'-Wno-strict-prototypes',
+	'-D_BSD_SOURCE',
+	'-D_DEFAULT_SOURCE',
+	'-D_XOPEN_SOURCE=600'
+]
+foreach option:cflags_options
+	if cc.has_argument(option)
+		cflags += option
 	endif
-	# To maintain the compatibility with the make build system
-	# mlx4_autoconf.h file is still generated.
-	# input array for meson member search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search", "struct member to search" ]
-	#
-	has_member_args = [
-		[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
-		'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
-	]
-	# input array for meson symbol search:
-	# [ "MACRO to define if found", "header for the search",
-	#   "symbol to search" ]
-	has_sym_args = [
-		[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
-		'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
-		[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
-		'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
-	]
-	config = configuration_data()
-	foreach arg:has_sym_args
-		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
-			dependencies: libs))
-	endforeach
-	foreach arg:has_member_args
-		file_prefix = '#include <' + arg[1] + '>'
-		config.set(arg[0], cc.has_member(arg[2], arg[3],
-			prefix: file_prefix, dependencies: libs))
-	endforeach
-	configure_file(output : 'mlx4_autoconf.h', configuration : config)
+endforeach
+if get_option('buildtype').contains('debug')
+	cflags += [ '-pedantic', '-DPEDANTIC' ]
+else
+	cflags += [ '-UPEDANTIC' ]
 endif
+# To maintain the compatibility with the make build system
+# mlx4_autoconf.h file is still generated.
+# input array for meson member search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search", "struct member to search" ]
+#
+has_member_args = [
+	[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
+	'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
+]
+# input array for meson symbol search:
+# [ "MACRO to define if found", "header for the search",
+#   "symbol to search" ]
+has_sym_args = [
+	[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
+	'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
+	[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
+	'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
+]
+config = configuration_data()
+foreach arg:has_sym_args
+	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
+		dependencies: libs))
+endforeach
+foreach arg:has_member_args
+	file_prefix = '#include <' + arg[1] + '>'
+	config.set(arg[0], cc.has_member(arg[2], arg[3],
+		prefix: file_prefix, dependencies: libs))
+endforeach
+configure_file(output : 'mlx4_autoconf.h', configuration : config)
+
 # Build Glue Library
-if pmd_dlopen and build
+if pmd_dlopen
 	dlopen_name = 'mlx4_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/raw/ifpga/meson.build b/drivers/raw/ifpga/meson.build
index d4027068d6..e2a4b8cccb 100644
--- a/drivers/raw/ifpga/meson.build
+++ b/drivers/raw/ifpga/meson.build
@@ -8,21 +8,20 @@ endif
 if not dep.found()
 	build = false
 	reason = 'missing dependency, "libfdt"'
+	subdir_done()
 endif
 
-if build
-	subdir('base')
-	objs = [base_objs]
+subdir('base')
+objs = [base_objs]
 
-	deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
-		'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
-	ext_deps += dep
+deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
+	'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
+ext_deps += dep
 
-	sources = files('ifpga_rawdev.c')
+sources = files('ifpga_rawdev.c')
 
-	includes += include_directories('base')
-	includes += include_directories('../../net/ipn3ke')
-	includes += include_directories('../../net/i40e')
+includes += include_directories('base')
+includes += include_directories('../../net/ipn3ke')
+includes += include_directories('../../net/i40e')
 
-	allow_experimental_apis = true
-endif
+allow_experimental_apis = true
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 2/6] net/mlx: add static ibverbs linkage with meson
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, John McNamara,
	Marko Kovacevic, Viacheslav Ovsiienko

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 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>
---
 doc/guides/nics/mlx4.rst        | 4 ++++
 doc/guides/nics/mlx5.rst        | 4 ++++
 drivers/common/mlx5/meson.build | 5 +++--
 drivers/net/mlx4/meson.build    | 5 +++--
 meson_options.txt               | 4 ++--
 5 files changed, 16 insertions(+), 6 deletions(-)

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 2411fb3461..ffab34d281 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -278,6 +278,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/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index be57558267..47ae1b65c2 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -7,6 +7,7 @@ if not is_linux
 	subdir_done()
 endif
 
+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 = '20.02.0'
@@ -22,8 +23,8 @@ 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()
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 6d2397b3cc..7513516764 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -8,6 +8,7 @@ if not is_linux
 	subdir_done()
 endif
 
+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'
@@ -23,8 +24,8 @@ 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()
diff --git a/meson_options.txt b/meson_options.txt
index 20be15fe6b..9e4923a4f1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -14,8 +14,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: '',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 3/6] buildtools: get static mlx dependencies for meson
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The shell script options-ibverbs-static.sh was used with make
in forcing static linkage of ibverbs libraries.

When choosing to link with a static dependency in meson,
the generated .pc file will not force such static linkage.
The solution will rely on using this script in meson.

If linking with libraries installed in a non-standard path,
an option -L is provided via EXTRA_LDFLAGS in case of using make.
With meson, tuning PKG_CONFIG_PATH for pkg-config should be enough.
When statically linking an application, the .pc file must save the
-L path so the application link will work without any extra option.
That's why --libs-only-l is replaced with --libs which includes -L.
Options which are neither -l or -L are filtered out because not needed
and can cause compilation issues with the legacy system using make.

The other change in this script is to drop the first occurrences of the
main library file (libiverbs.a). Only the last occurrence is kept.
It fixes some undefined references when linking a static application
using libdpdk.pc.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/options-ibverbs-static.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/buildtools/options-ibverbs-static.sh b/buildtools/options-ibverbs-static.sh
index 0f285a343b..0740a711ff 100755
--- a/buildtools/options-ibverbs-static.sh
+++ b/buildtools/options-ibverbs-static.sh
@@ -9,6 +9,13 @@
 #
 # PKG_CONFIG_PATH may be required to be set if libibverbs.pc is not installed.
 
-pkg-config --libs-only-l --static libibverbs |
+lib='libibverbs'
+deps='pthread|nl'
+
+pkg-config --libs --static $lib |
 	tr '[:space:]' '\n' |
-	sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+	sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," |   # explicit .a
+	sed -n '/^-[Ll]/p' |   # extra link options may break with make
+	tac |
+	awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
+	tac
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 4/6] net/mlx: workaround static linkage with meson
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
                     ` (2 preceding siblings ...)
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

If ibverbs_link is static and the application choose to link DPDK
as static libraries, both PMD and ibverbs libraries must be linked
as static libraries. And the dependencies of ibverbs (netlink) must
still be linked as shared libraries.

Unfortunately, meson forget about the static requirement for ibverbs
when generating the .pc file.
As a result, libibverbs, libmlx4, libmlx5 are listed in Requires.private
section (allowing to be linked as shared libraries) and libnl is missing.

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

In order to avoid meson suggesting shared libraries in the section
Requires.private of the .pc file, the dependency object is recreated
with declare_dependency():
	- cflags are extracted the libibverbs.pc
	- ldflags, from libibverbs.pc, are processed to force
	static flavor of ibverbs libraries, thanks to this syntax:
			-l:libfoo.a

Fixes: 83fff714bd27 ("net/mlx: add static ibverbs linkage with meson")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/meson.build          |  2 ++
 drivers/common/mlx5/meson.build | 12 +++++++++++-
 drivers/net/mlx4/meson.build    | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index 0f563d89a3..9812917e50 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -3,9 +3,11 @@
 
 subdir('pmdinfogen')
 
+pkgconf = find_program('pkg-config', 'pkgconf', required: false)
 pmdinfo = find_program('gen-pmdinfo-cfile.sh')
 list_dir_globs = find_program('list-dir-globs.py')
 check_experimental_syms = find_program('check-experimental-syms.sh')
+ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
 
 # set up map-to-def script using python, either built-in or external
 python3 = import('python').find_installation(required: false)
diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 47ae1b65c2..4e987ed277 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -29,16 +29,26 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 		subdir_done()
 	endif
 endforeach
+if static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 allow_experimental_apis = true
 deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
-ext_deps += libs
 sources = files(
 	'mlx5_devx_cmds.c',
 	'mlx5_common.c',
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 7513516764..290bd1e268 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -29,16 +29,26 @@ foreach libname:libnames
 		lib = cc.find_library(libname, required:false)
 	endif
 	if lib.found()
-		libs += [ lib ]
+		libs += lib
+		if not static_ibverbs
+			ext_deps += lib
+		endif
 	else
 		build = false
 		reason = 'missing dependency, "' + libname + '"'
 		subdir_done()
 	endif
 endforeach
+if static_ibverbs
+	# Build without adding shared libs to Requires.private
+	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
+	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+	# Add static deps ldflags to internal apps and Libs.private
+	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
+	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
+endif
 
 allow_experimental_apis = true
-ext_deps += libs
 sources = files(
 	'mlx4.c',
 	'mlx4_ethdev.c',
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 5/6] net/mlx: rename meson variable for dlopen option
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
                     ` (3 preceding siblings ...)
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
  2020-02-13 13:57   ` [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson Raslan Darawsheh
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko

The name of the variable pmd_dlopen is confusing because
it can be understood as true if the PMD is dlopen,
whereas it means the ibverbs glue layer is a dlopen library.
That's why it is renamed dlopen_ibverbs.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/mlx5/meson.build | 8 ++++----
 drivers/net/mlx4/meson.build    | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 4e987ed277..0fe086136a 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -8,11 +8,11 @@ if not is_linux
 endif
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx5_glue.so'
 LIB_GLUE_VERSION = '20.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX5_GLUE="@0@"'.format(LIB_GLUE),
@@ -54,7 +54,7 @@ sources = files(
 	'mlx5_common.c',
 	'mlx5_nl.c',
 )
-if not pmd_dlopen
+if not dlopen_ibverbs
 	sources += files('mlx5_glue.c')
 endif
 cflags_options = [
@@ -193,7 +193,7 @@ endforeach
 configure_file(output : 'mlx5_autoconf.h', configuration : config)
 
 # Build Glue Library
-if pmd_dlopen
+if dlopen_ibverbs
 	dlopen_name = 'mlx5_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index 290bd1e268..f66e70f4d1 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -9,11 +9,11 @@ if not is_linux
 endif
 
 static_ibverbs = (get_option('ibverbs_link') == 'static')
-pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
+dlopen_ibverbs = (get_option('ibverbs_link') == 'dlopen')
 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
 LIB_GLUE_VERSION = '18.02.0'
 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
-if pmd_dlopen
+if dlopen_ibverbs
 	dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
 	cflags += [
 		'-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
@@ -61,7 +61,7 @@ sources = files(
 	'mlx4_txq.c',
 	'mlx4_utils.c',
 )
-if not pmd_dlopen
+if not dlopen_ibverbs
 	sources += files('mlx4_glue.c')
 endif
 cflags_options = [
@@ -113,7 +113,7 @@ endforeach
 configure_file(output : 'mlx4_autoconf.h', configuration : config)
 
 # Build Glue Library
-if pmd_dlopen
+if dlopen_ibverbs
 	dlopen_name = 'mlx4_glue'
 	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
 	dlopen_so_version = LIB_GLUE_VERSION
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* [dpdk-dev] [PATCH v5 6/6] net/mlx: fix overlinking with meson and glue dlopen
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
                     ` (4 preceding siblings ...)
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
@ 2020-02-12 22:07   ` Thomas Monjalon
  2020-02-13 13:57   ` [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson Raslan Darawsheh
  6 siblings, 0 replies; 59+ messages in thread
From: Thomas Monjalon @ 2020-02-12 22:07 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, stable, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Nélio Laranjeiro

If ibverbs_link is dlopen, the PMD and application should not
be linked with ibverbs, but the glue library is.
Unfortunately the ibverbs dependency was exported in the
variable ext_deps, so there were overlinking.

It is fixed by not exporting the dependency in ext_deps,
and recreating a limited dependency object for cflags only.

Fixes: 1dd7c7e38c19 ("net/mlx4: support meson build")
Fixes: 96d7c62a70c7 ("net/mlx5: support meson build")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/common/mlx5/meson.build | 6 ++++--
 drivers/net/mlx4/meson.build    | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 0fe086136a..cfc178257d 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -29,7 +29,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -38,10 +38,12 @@ foreach libname:libnames
 		subdir_done()
 	endif
 endforeach
-if static_ibverbs
+if static_ibverbs or dlopen_ibverbs
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
index f66e70f4d1..c598745730 100644
--- a/drivers/net/mlx4/meson.build
+++ b/drivers/net/mlx4/meson.build
@@ -30,7 +30,7 @@ foreach libname:libnames
 	endif
 	if lib.found()
 		libs += lib
-		if not static_ibverbs
+		if not static_ibverbs and not dlopen_ibverbs
 			ext_deps += lib
 		endif
 	else
@@ -39,10 +39,12 @@ foreach libname:libnames
 		subdir_done()
 	endif
 endforeach
-if static_ibverbs
+if static_ibverbs or dlopen_ibverbs
 	# Build without adding shared libs to Requires.private
 	ibv_cflags = run_command(pkgconf, '--cflags', 'libibverbs').stdout()
 	ext_deps += declare_dependency(compile_args: ibv_cflags.split())
+endif
+if static_ibverbs
 	# Add static deps ldflags to internal apps and Libs.private
 	ibv_ldflags = run_command(ldflags_ibverbs_static, check:true).stdout()
 	ext_deps += declare_dependency(link_args:ibv_ldflags.split())
-- 
2.25.0


^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable Thomas Monjalon
@ 2020-02-13  0:25     ` Xu, Rosen
  0 siblings, 0 replies; 59+ messages in thread
From: Xu, Rosen @ 2020-02-13  0:25 UTC (permalink / raw)
  To: Thomas Monjalon, dev
  Cc: Richardson, Bruce, Matan Azrad, Shahaf Shuler,
	Viacheslav Ovsiienko, Zhang, Tianfei

Hi,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, February 13, 2020 6:07
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Matan Azrad
> <matan@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>;
> Viacheslav Ovsiienko <viacheslavo@mellanox.com>; Xu, Rosen
> <rosen.xu@intel.com>; Zhang, Tianfei <tianfei.zhang@intel.com>
> Subject: [PATCH v5 1/6] drivers: cleanup meson build variable
> 
> The variable build is already initialized as true in drivers/meson.build.
> Duplicate initializations can be removed from mlx.
> 
> When the variable build is set to false, it is easier to call
> subdir_done() than branch the rest of the code on build condition.
> 
> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/common/mlx5/meson.build | 293 ++++++++++++++++----------------
> drivers/net/ipn3ke/meson.build  |  17 +-
>  drivers/net/mlx4/meson.build    | 131 +++++++-------
>  drivers/raw/ifpga/meson.build   |  23 ++-
>  4 files changed, 230 insertions(+), 234 deletions(-)
> 
> diff --git a/drivers/common/mlx5/meson.build
> b/drivers/common/mlx5/meson.build index 2b704107cd..be57558267 100644
> --- a/drivers/common/mlx5/meson.build
> +++ b/drivers/common/mlx5/meson.build
> @@ -6,7 +6,6 @@ if not is_linux
>  	reason = 'only supported on Linux'
>  	subdir_done()
>  endif
> -build = true
> 
>  pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')  LIB_GLUE_BASE =
> 'librte_pmd_mlx5_glue.so'
> @@ -32,158 +31,158 @@ foreach libname:libnames
>  	else
>  		build = false
>  		reason = 'missing dependency, "' + libname + '"'
> +		subdir_done()
>  	endif
>  endforeach
> 
> -if build
> -	allow_experimental_apis = true
> -	deps += ['hash', 'pci', 'net', 'eal', 'kvargs']
> -	ext_deps += libs
> -	sources = files(
> -		'mlx5_devx_cmds.c',
> -		'mlx5_common.c',
> -		'mlx5_nl.c',
> -	)
> -	if not pmd_dlopen
> -		sources += files('mlx5_glue.c')
> -	endif
> -	cflags_options = [
> -		'-std=c11',
> -		'-Wno-strict-prototypes',
> -		'-D_BSD_SOURCE',
> -		'-D_DEFAULT_SOURCE',
> -		'-D_XOPEN_SOURCE=600'
> -	]
> -	foreach option:cflags_options
> -		if cc.has_argument(option)
> -			cflags += option
> -		endif
> -	endforeach
> -	if get_option('buildtype').contains('debug')
> -		cflags += [ '-pedantic', '-DPEDANTIC' ]
> -	else
> -		cflags += [ '-UPEDANTIC' ]
> +allow_experimental_apis = true
> +deps += ['hash', 'pci', 'net', 'eal', 'kvargs'] ext_deps += libs
> +sources = files(
> +	'mlx5_devx_cmds.c',
> +	'mlx5_common.c',
> +	'mlx5_nl.c',
> +)
> +if not pmd_dlopen
> +	sources += files('mlx5_glue.c')
> +endif
> +cflags_options = [
> +	'-std=c11',
> +	'-Wno-strict-prototypes',
> +	'-D_BSD_SOURCE',
> +	'-D_DEFAULT_SOURCE',
> +	'-D_XOPEN_SOURCE=600'
> +]
> +foreach option:cflags_options
> +	if cc.has_argument(option)
> +		cflags += option
>  	endif
> -	# To maintain the compatibility with the make build system
> -	# mlx5_autoconf.h file is still generated.
> -	# input array for meson member search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search", "struct member to search" ]
> -	has_member_args = [
> -		[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
> -		'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
> -		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42',
> 'infiniband/verbs.h',
> -		'struct ibv_counter_set_init_attr', 'counter_set_id' ],
> -		[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45',
> 'infiniband/verbs.h',
> -		'struct ibv_counters_init_attr', 'comp_mask' ],
> -	]
> -	# input array for meson symbol search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search" ]
> -	has_sym_args = [
> -		[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
> -		[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
> -		[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
> -		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
> -		[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD',
> 'infiniband/mlx5dv.h',
> -		'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
> -		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_create_flow_action_packet_reformat' ],
> -		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
> -		'IBV_FLOW_SPEC_MPLS' ],
> -		[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING',
> 'infiniband/verbs.h',
> -		'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
> -		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING',
> 'infiniband/verbs.h',
> -		'IBV_WQ_FLAG_RX_END_PADDING' ],
> -		[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_query_devx_port' ],
> -		[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_obj_create' ],
> -		[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
> -		'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
> -		[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_obj_query_async' ],
> -		[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR',
> 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_dest_devx_tir' ],
> -		[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
> -		'mlx5dv_devx_get_event' ],
> -		[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER',
> 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_flow_meter' ],
> -		[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD',
> 'infiniband/mlx5dv.h',
> -		'MLX5_MMAP_GET_NC_PAGES_CMD' ],
> -		[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
> -		'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
> -		[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
> -		'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
> -		[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
> -		'mlx5dv_dr_action_create_push_vlan' ],
> -		[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
> -		[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseKR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseCR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseSR4_Full' ],
> -		[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_40000baseLR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseKR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseCR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseSR4_Full' ],
> -		[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
> -		'SUPPORTED_56000baseLR4_Full' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
> -		[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
> -		'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
> -		[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
> -		'IFLA_NUM_VF' ],
> -		[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
> -		'IFLA_EXT_MASK' ],
> -		[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
> -		'IFLA_PHYS_SWITCH_ID' ],
> -		[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
> -		'IFLA_PHYS_PORT_NAME' ],
> -		[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
> -		'RDMA_NL_NLDEV' ],
> -		[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_CMD_GET' ],
> -		[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_CMD_PORT_GET' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_DEV_INDEX' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_DEV_NAME' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_PORT_INDEX' ],
> -		[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX',
> 'rdma/rdma_netlink.h',
> -		'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
> -		[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
> -		'mlx5dv_dump_dr_domain'],
> -		[ 'HAVE_DEVLINK', 'linux/devlink.h',
> 'DEVLINK_GENL_NAME' ],
> -	]
> -	config = configuration_data()
> -	foreach arg:has_sym_args
> -		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> -			dependencies: libs))
> -	endforeach
> -	foreach arg:has_member_args
> -		file_prefix = '#include <' + arg[1] + '>'
> -		config.set(arg[0], cc.has_member(arg[2], arg[3],
> -			prefix : file_prefix, dependencies: libs))
> -	endforeach
> -	configure_file(output : 'mlx5_autoconf.h', configuration : config)
> +endforeach
> +if get_option('buildtype').contains('debug')
> +	cflags += [ '-pedantic', '-DPEDANTIC' ] else
> +	cflags += [ '-UPEDANTIC' ]
>  endif
> +# To maintain the compatibility with the make build system #
> +mlx5_autoconf.h file is still generated.
> +# input array for meson member search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search", "struct member to search" ]
> +has_member_args = [
> +	[ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h',
> +	'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ],
> +	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h',
> +	'struct ibv_counter_set_init_attr', 'counter_set_id' ],
> +	[ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h',
> +	'struct ibv_counters_init_attr', 'comp_mask' ], ] # input array for
> +meson symbol search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search" ]
> +has_sym_args = [
> +	[ 'HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT',
> 'infiniband/mlx5dv.h',
> +	'MLX5DV_CQE_RES_FORMAT_CSUM_STRIDX' ],
> +	[ 'HAVE_IBV_DEVICE_TUNNEL_SUPPORT', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS' ],
> +	[ 'HAVE_IBV_MLX5_MOD_MPW', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED' ],
> +	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_COMP', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
> +	[ 'HAVE_IBV_MLX5_MOD_CQE_128B_PAD', 'infiniband/mlx5dv.h',
> +	'MLX5DV_CQ_INIT_ATTR_FLAGS_CQE_PAD' ],
> +	[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_create_flow_action_packet_reformat' ],
> +	[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
> +	'IBV_FLOW_SPEC_MPLS' ],
> +	[ 'HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING',
> 'infiniband/verbs.h',
> +	'IBV_WQ_FLAGS_PCI_WRITE_END_PADDING' ],
> +	[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
> +	'IBV_WQ_FLAG_RX_END_PADDING' ],
> +	[ 'HAVE_MLX5DV_DR_DEVX_PORT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_query_devx_port' ],
> +	[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_obj_create' ],
> +	[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
> +	'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
> +	[ 'HAVE_IBV_DEVX_ASYNC', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_obj_query_async' ],
> +	[ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_dest_devx_tir' ],
> +	[ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
> +	'mlx5dv_devx_get_event' ],
> +	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_flow_meter' ],
> +	[ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD',
> 'infiniband/mlx5dv.h',
> +	'MLX5_MMAP_GET_NC_PAGES_CMD' ],
> +	[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
> +	'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
> +	[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
> +	'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
> +	[ 'HAVE_MLX5DV_DR_VLAN', 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_push_vlan' ],
> +	[ 'HAVE_IBV_VAR', 'infiniband/mlx5dv.h', 'mlx5dv_alloc_var' ],
> +	[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseKR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseCR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseSR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseSR4_Full' ],
> +	[ 'HAVE_SUPPORTED_40000baseLR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_40000baseLR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseKR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseKR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseCR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseCR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseSR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseSR4_Full' ],
> +	[ 'HAVE_SUPPORTED_56000baseLR4_Full', 'linux/ethtool.h',
> +	'SUPPORTED_56000baseLR4_Full' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_25G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_25000baseCR_Full_BIT' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_50G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],
> +	[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',
> +	'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],
> +	[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',
> +	'IFLA_NUM_VF' ],
> +	[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',
> +	'IFLA_EXT_MASK' ],
> +	[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',
> +	'IFLA_PHYS_SWITCH_ID' ],
> +	[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',
> +	'IFLA_PHYS_PORT_NAME' ],
> +	[ 'HAVE_RDMA_NL_NLDEV', 'rdma/rdma_netlink.h',
> +	'RDMA_NL_NLDEV' ],
> +	[ 'HAVE_RDMA_NLDEV_CMD_GET', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_CMD_GET' ],
> +	[ 'HAVE_RDMA_NLDEV_CMD_PORT_GET', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_CMD_PORT_GET' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_DEV_INDEX' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_DEV_NAME', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_DEV_NAME' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_PORT_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_PORT_INDEX' ],
> +	[ 'HAVE_RDMA_NLDEV_ATTR_NDEV_INDEX', 'rdma/rdma_netlink.h',
> +	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
> +	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
> +	'mlx5dv_dump_dr_domain'],
> +	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ], ]
> config =
> +configuration_data() foreach arg:has_sym_args
> +	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> +		dependencies: libs))
> +endforeach
> +foreach arg:has_member_args
> +	file_prefix = '#include <' + arg[1] + '>'
> +	config.set(arg[0], cc.has_member(arg[2], arg[3],
> +		prefix : file_prefix, dependencies: libs)) endforeach
> +configure_file(output : 'mlx5_autoconf.h', configuration : config)
> +
>  # Build Glue Library
> -if pmd_dlopen and build
> +if pmd_dlopen
>  	dlopen_name = 'mlx5_glue'
>  	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
>  	dlopen_so_version = LIB_GLUE_VERSION
> diff --git a/drivers/net/ipn3ke/meson.build
> b/drivers/net/ipn3ke/meson.build index bfec592aba..f19083af15 100644
> --- a/drivers/net/ipn3ke/meson.build
> +++ b/drivers/net/ipn3ke/meson.build
> @@ -16,16 +16,15 @@ endif
>  if not dep.found()
>  	build = false
>  	reason = 'missing dependency, "libfdt"'
> +	subdir_done()
>  endif
> 
> -if build
> -	allow_experimental_apis = true
> +allow_experimental_apis = true
> 
> -	includes += include_directories('../../raw/ifpga')
> +includes += include_directories('../../raw/ifpga')
> 
> -	sources += files('ipn3ke_ethdev.c',
> -		'ipn3ke_representor.c',
> -		'ipn3ke_tm.c',
> -		'ipn3ke_flow.c')
> -	deps += ['bus_ifpga', 'ethdev', 'sched']
> -endif
> +sources += files('ipn3ke_ethdev.c',
> +	'ipn3ke_representor.c',
> +	'ipn3ke_tm.c',
> +	'ipn3ke_flow.c')
> +deps += ['bus_ifpga', 'ethdev', 'sched']
> diff --git a/drivers/net/mlx4/meson.build b/drivers/net/mlx4/meson.build
> index 0260c5dc59..6d2397b3cc 100644
> --- a/drivers/net/mlx4/meson.build
> +++ b/drivers/net/mlx4/meson.build
> @@ -7,7 +7,6 @@ if not is_linux
>  	reason = 'only supported on Linux'
>  	subdir_done()
>  endif
> -build = true
> 
>  pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')  LIB_GLUE_BASE =
> 'librte_pmd_mlx4_glue.so'
> @@ -33,77 +32,77 @@ foreach libname:libnames
>  	else
>  		build = false
>  		reason = 'missing dependency, "' + libname + '"'
> +		subdir_done()
>  	endif
>  endforeach
> 
> -if build
> -	allow_experimental_apis = true
> -	ext_deps += libs
> -	sources = files(
> -		'mlx4.c',
> -		'mlx4_ethdev.c',
> -		'mlx4_flow.c',
> -		'mlx4_intr.c',
> -		'mlx4_mp.c',
> -		'mlx4_mr.c',
> -		'mlx4_rxq.c',
> -		'mlx4_rxtx.c',
> -		'mlx4_txq.c',
> -		'mlx4_utils.c',
> -	)
> -	if not pmd_dlopen
> -		sources += files('mlx4_glue.c')
> -	endif
> -	cflags_options = [
> -		'-std=c11',
> -		'-Wno-strict-prototypes',
> -		'-D_BSD_SOURCE',
> -		'-D_DEFAULT_SOURCE',
> -		'-D_XOPEN_SOURCE=600'
> -	]
> -	foreach option:cflags_options
> -		if cc.has_argument(option)
> -			cflags += option
> -		endif
> -	endforeach
> -	if get_option('buildtype').contains('debug')
> -		cflags += [ '-pedantic', '-DPEDANTIC' ]
> -	else
> -		cflags += [ '-UPEDANTIC' ]
> +allow_experimental_apis = true
> +ext_deps += libs
> +sources = files(
> +	'mlx4.c',
> +	'mlx4_ethdev.c',
> +	'mlx4_flow.c',
> +	'mlx4_intr.c',
> +	'mlx4_mp.c',
> +	'mlx4_mr.c',
> +	'mlx4_rxq.c',
> +	'mlx4_rxtx.c',
> +	'mlx4_txq.c',
> +	'mlx4_utils.c',
> +)
> +if not pmd_dlopen
> +	sources += files('mlx4_glue.c')
> +endif
> +cflags_options = [
> +	'-std=c11',
> +	'-Wno-strict-prototypes',
> +	'-D_BSD_SOURCE',
> +	'-D_DEFAULT_SOURCE',
> +	'-D_XOPEN_SOURCE=600'
> +]
> +foreach option:cflags_options
> +	if cc.has_argument(option)
> +		cflags += option
>  	endif
> -	# To maintain the compatibility with the make build system
> -	# mlx4_autoconf.h file is still generated.
> -	# input array for meson member search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search", "struct member to search" ]
> -	#
> -	has_member_args = [
> -		[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
> -		'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
> -	]
> -	# input array for meson symbol search:
> -	# [ "MACRO to define if found", "header for the search",
> -	#   "symbol to search" ]
> -	has_sym_args = [
> -		[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS',
> 'infiniband/mlx4dv.h',
> -		'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
> -		[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET',
> 'infiniband/mlx4dv.h',
> -		'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
> -	]
> -	config = configuration_data()
> -	foreach arg:has_sym_args
> -		config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> -			dependencies: libs))
> -	endforeach
> -	foreach arg:has_member_args
> -		file_prefix = '#include <' + arg[1] + '>'
> -		config.set(arg[0], cc.has_member(arg[2], arg[3],
> -			prefix: file_prefix, dependencies: libs))
> -	endforeach
> -	configure_file(output : 'mlx4_autoconf.h', configuration : config)
> +endforeach
> +if get_option('buildtype').contains('debug')
> +	cflags += [ '-pedantic', '-DPEDANTIC' ] else
> +	cflags += [ '-UPEDANTIC' ]
>  endif
> +# To maintain the compatibility with the make build system #
> +mlx4_autoconf.h file is still generated.
> +# input array for meson member search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search", "struct member to search" ]
> +#
> +has_member_args = [
> +	[ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
> +	'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ], ] # input array for
> meson
> +symbol search:
> +# [ "MACRO to define if found", "header for the search",
> +#   "symbol to search" ]
> +has_sym_args = [
> +	[ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
> +	'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
> +	[ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
> +	'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
> +]
> +config = configuration_data()
> +foreach arg:has_sym_args
> +	config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
> +		dependencies: libs))
> +endforeach
> +foreach arg:has_member_args
> +	file_prefix = '#include <' + arg[1] + '>'
> +	config.set(arg[0], cc.has_member(arg[2], arg[3],
> +		prefix: file_prefix, dependencies: libs)) endforeach
> +configure_file(output : 'mlx4_autoconf.h', configuration : config)
> +
>  # Build Glue Library
> -if pmd_dlopen and build
> +if pmd_dlopen
>  	dlopen_name = 'mlx4_glue'
>  	dlopen_lib_name = driver_name_fmt.format(dlopen_name)
>  	dlopen_so_version = LIB_GLUE_VERSION
> diff --git a/drivers/raw/ifpga/meson.build b/drivers/raw/ifpga/meson.build
> index d4027068d6..e2a4b8cccb 100644
> --- a/drivers/raw/ifpga/meson.build
> +++ b/drivers/raw/ifpga/meson.build
> @@ -8,21 +8,20 @@ endif
>  if not dep.found()
>  	build = false
>  	reason = 'missing dependency, "libfdt"'
> +	subdir_done()
>  endif
> 
> -if build
> -	subdir('base')
> -	objs = [base_objs]
> +subdir('base')
> +objs = [base_objs]
> 
> -	deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
> -		'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke']
> -	ext_deps += dep
> +deps += ['ethdev', 'rawdev', 'pci', 'bus_pci', 'kvargs',
> +	'bus_vdev', 'bus_ifpga', 'net', 'pmd_i40e', 'pmd_ipn3ke'] ext_deps +=
> +dep
> 
> -	sources = files('ifpga_rawdev.c')
> +sources = files('ifpga_rawdev.c')
> 
> -	includes += include_directories('base')
> -	includes += include_directories('../../net/ipn3ke')
> -	includes += include_directories('../../net/i40e')
> +includes += include_directories('base') includes +=
> +include_directories('../../net/ipn3ke')
> +includes += include_directories('../../net/i40e')
> 
> -	allow_experimental_apis = true
> -endif
> +allow_experimental_apis = true
> --
> 2.25.0

Acked-by: Rosen Xu <rosen.xu@intel.com>

^ permalink raw reply	[flat|nested] 59+ messages in thread

* Re: [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson
  2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
                     ` (5 preceding siblings ...)
  2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
@ 2020-02-13 13:57   ` Raslan Darawsheh
  6 siblings, 0 replies; 59+ messages in thread
From: Raslan Darawsheh @ 2020-02-13 13:57 UTC (permalink / raw)
  To: Thomas Monjalon, dev; +Cc: bruce.richardson

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Thomas Monjalon
> Sent: Thursday, February 13, 2020 12:07 AM
> To: dev@dpdk.org
> Cc: bruce.richardson@intel.com
> Subject: [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson
> 
> This is the follow-up of the feature I added one year ago:
> static linkage of libibverbs in mlx PMDs.
> The first implementation was focused on "make".
> This second round does the same with "meson".
> 
> With the meson option ibverbs_link, only the mode "shared"
> was working correctly.
> This patchset adds the mode "static" and fixes the mode "dlopen".
> 
> 
> changes in v5:
> - fix build if pkg-config/pkgconf is missing (e.g. Windows)
> 
> changes in v4:
> - fix lib ordering
> - simplify conditions by using subdir_done()
> 
> changes in v3:
> - get cflags with pkg-config invocation
> - drop addition of global variable hidden_deps
> - remove overlinking in dlopen mode
> 
> changes in v2:
> - split mlx patch for normal addition and workarounds
> - fix ldflags for ibverbs installed in a standard directory
> - fix libs order leading to undefined references
> - add doc for hidden_deps
> - improve explanations in commit logs
> 
> 
> Thomas Monjalon (6):
>   drivers: cleanup meson build variable
>   net/mlx: add static ibverbs linkage with meson
>   buildtools: get static mlx dependencies for meson
>   net/mlx: workaround static linkage with meson
>   net/mlx: rename meson variable for dlopen option
>   net/mlx: fix overlinking with meson and glue dlopen
> 
>  buildtools/meson.build               |   2 +
>  buildtools/options-ibverbs-static.sh |  11 +-
>  doc/guides/nics/mlx4.rst             |   4 +
>  doc/guides/nics/mlx5.rst             |   4 +
>  drivers/common/mlx5/meson.build      | 314 ++++++++++++++-------------
>  drivers/net/ipn3ke/meson.build       |  17 +-
>  drivers/net/mlx4/meson.build         | 154 +++++++------
>  drivers/raw/ifpga/meson.build        |  23 +-
>  meson_options.txt                    |   4 +-
>  9 files changed, 286 insertions(+), 247 deletions(-)
> 
> --
> 2.25.0


Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2020-02-13 13:57 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16  7:16 [dpdk-dev] [PATCH 0/3] add static ibverbs in meson Thomas Monjalon
2020-01-16  7:16 ` [dpdk-dev] [PATCH 1/3] buildtools: rework static pkg-config script Thomas Monjalon
2020-01-16  7:16 ` [dpdk-dev] [PATCH 2/3] build: allow to hide dependencies from pkg-config Thomas Monjalon
2020-01-17 17:34   ` Bruce Richardson
2020-01-16  7:16 ` [dpdk-dev] [PATCH 3/3] net/mlx: support static ibverbs linkage with meson Thomas Monjalon
2020-01-27 15:43 ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Thomas Monjalon
2020-01-27 15:43   ` [dpdk-dev] [PATCH v2 1/4] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 2/4] buildtools: get static mlx dependencies for meson Thomas Monjalon
2020-01-29 15:37     ` Bruce Richardson
2020-01-29 17:48       ` Thomas Monjalon
2020-01-29 17:50         ` Bruce Richardson
2020-01-29 18:49           ` Thomas Monjalon
2020-01-29 17:48       ` Bruce Richardson
2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 3/4] build: allow hiding dependencies from pkg-config Thomas Monjalon
2020-01-27 15:44   ` [dpdk-dev] [PATCH v2 4/4] net/mlx: workaround static linkage with meson Thomas Monjalon
2020-02-04 11:48   ` [dpdk-dev] [PATCH v2 0/4] add static ibverbs in meson Bruce Richardson
2020-02-04 14:27     ` Thomas Monjalon
2020-02-04 14:33       ` Bruce Richardson
2020-02-04 15:14         ` Thomas Monjalon
2020-02-04 15:20           ` Bruce Richardson
2020-02-11  1:19   ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking " Thomas Monjalon
2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 1/5] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 2/5] buildtools: get static mlx dependencies for meson Thomas Monjalon
2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson Thomas Monjalon
2020-02-11 11:29       ` Bruce Richardson
2020-02-11 11:36         ` Thomas Monjalon
2020-02-11 11:43           ` Bruce Richardson
2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 4/5] net/mlx: rename meson variable for dlopen option Thomas Monjalon
2020-02-11  1:19     ` [dpdk-dev] [PATCH v3 5/5] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
2020-02-11 11:32       ` Bruce Richardson
2020-02-11 11:34         ` Thomas Monjalon
2020-02-11 11:33     ` [dpdk-dev] [PATCH v3 0/5] mlx ibverbs linking in meson Bruce Richardson
2020-02-12  1:59 ` [dpdk-dev] [PATCH v4 0/6] " Thomas Monjalon
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 1/6] drivers: cleanup meson build variable Thomas Monjalon
2020-02-12  9:26     ` Xu, Rosen
2020-02-12  9:32       ` Thomas Monjalon
2020-02-12 15:04         ` [dpdk-dev] [dpdklab] " Jeremy Plsek
2020-02-12 15:18           ` Jeremy Plsek
2020-02-12 16:30             ` Thomas Monjalon
2020-02-12 16:36               ` Jeremy Plsek
2020-02-12 16:42                 ` Thomas Monjalon
2020-02-12 16:46                   ` Jeremy Plsek
2020-02-12 17:38                     ` Thomas Monjalon
2020-02-12 18:03                       ` Jeremy Plsek
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
2020-02-12  1:59   ` [dpdk-dev] [PATCH v4 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
2020-02-12  2:08   ` [dpdk-dev] [PATCH v4 0/6] mlx ibverbs linking in meson Thomas Monjalon
2020-02-12 22:07 ` [dpdk-dev] [PATCH v5 " Thomas Monjalon
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 1/6] drivers: cleanup meson build variable Thomas Monjalon
2020-02-13  0:25     ` Xu, Rosen
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 2/6] net/mlx: add static ibverbs linkage with meson Thomas Monjalon
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 3/6] buildtools: get static mlx dependencies for meson Thomas Monjalon
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 4/6] net/mlx: workaround static linkage with meson Thomas Monjalon
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 5/6] net/mlx: rename meson variable for dlopen option Thomas Monjalon
2020-02-12 22:07   ` [dpdk-dev] [PATCH v5 6/6] net/mlx: fix overlinking with meson and glue dlopen Thomas Monjalon
2020-02-13 13:57   ` [dpdk-dev] [PATCH v5 0/6] mlx ibverbs linking in meson Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).