New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkgconfig: Pull dependencies of static dependencies #6393
base: master
Are you sure you want to change the base?
Conversation
If a dependency is statically linked (i.e. embedded), it should be "transparent" from the pkg-config perspective. Here "transparent" means that the dependency should not be visible and its dependencies should appear in the private part of the generated .pc file. In current version of meson, such required static library is exposed the same way as a shared library. Such case of embedded dependency (with static linking) is fixed by hiding the dependency ("else" clause) and adding its dependencies as requirements. The dependencies of the dependency are found by filtering link_args, assuming path separator (in full path) is not present in such dependency. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
if obj.static: | ||
# in case of embedded static dependency | ||
for arg in obj.link_args: | ||
if not os.sep in arg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Flake8] test for membership should be 'not in' (see on Sider)
Rule |
---|
E713 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most importantly, this requires a unit test. See test_pkgconfig_gen_deps()
in run_unittests.py
, and test cases/common/47 pkgconfig-gen
for arg in obj.link_args: | ||
if not os.sep in arg: | ||
# pull external dependencies | ||
processed_reqs.append(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a link_arg, it should go to processed_libs, I think. processed_reqs is for pkg-config names.
if obj.static: | ||
# in case of embedded static dependency | ||
for arg in obj.link_args: | ||
if not os.sep in arg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this check? I guess it's because static libs are replaced by full path to .a file, and shared libraries are kept as -lfoo arg? Please add a comment explaining it. I would rather check with os.path.isabs()
or endswith('.a')
because pc file could contain / on Windows I guess?
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 2c0dd7b ("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: mesonbuild/meson#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> Signed-off-by: 0-day Robot <robot@bytheb.org>
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: mesonbuild/meson#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> Signed-off-by: 0-day Robot <robot@bytheb.org>
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: mesonbuild/meson#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> Signed-off-by: 0-day Robot <robot@bytheb.org>
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: mesonbuild/meson#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> Signed-off-by: 0-day Robot <robot@bytheb.org>
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: mesonbuild/meson#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> Signed-off-by: 0-day Robot <robot@bytheb.org>
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: mesonbuild/meson#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 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: mesonbuild/meson#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 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: mesonbuild/meson#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: 6affeab ("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>
[ upstream commit af33115 ] 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: mesonbuild/meson#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: 6affeab ("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>
[ upstream commit af33115 ] 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: mesonbuild/meson#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: 6affeab ("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 a dependency is statically linked (i.e. embedded),
it should be "transparent" from the pkg-config perspective.
Here "transparent" means that the dependency should not be visible
and its dependencies should appear in the private part
of the generated .pc file.
In current version of meson, such required static library is exposed
the same way as a shared library.
Such case of embedded dependency (with static linking)
is fixed by hiding the dependency ("else" clause) and adding
its dependencies as requirements.
The dependencies of the dependency are found by filtering link_args,
assuming path separator (in full path) is not present in such dependency.