]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx: workaround static linkage with meson
authorThomas Monjalon <thomas@monjalon.net>
Wed, 12 Feb 2020 22:07:06 +0000 (23:07 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 14 Feb 2020 11:42:13 +0000 (12:42 +0100)
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: 6affeabaf321 ("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
drivers/common/mlx5/meson.build
drivers/net/mlx4/meson.build

index 0f563d89a3f72950070b93227eda4752a03ee99f..9812917e502807429b71b099fc989c32e7f72e00 100644 (file)
@@ -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)
index 206ef75ca29ec67eb08b9e3620c04a80e341f627..089494e1f8a4aacb23cea3079f0cfeb5e1f6f58f 100644 (file)
@@ -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',
index 7513516764fbb6b0f5fd3e5b2178aa6b59471d90..290bd1e2680df23f5a7009a63834f4a7f6001c53 100644 (file)
@@ -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',