[dpdk-dev] [PATCH v3 3/5] net/mlx: workaround static linkage with meson
bruce.richardson at intel.com
Tue Feb 11 12:43:05 CET 2020
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 at monjalon.net>
> > > Signed-off-by: Bruce Richardson <bruce.richardson at 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.
More information about the dev