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
1.2.1: issue with pc.generate() when it is build only shared library. #12225
Comments
Other scenarios to check:
|
Currently generated libcacard.pc:
None of the header files ${includedir}/cacard includes glib, nss or libpcsclite header files so API defined in those headers do not depends on these libraries headers. |
In the general case we do need to assume they might, which is exactly why we intentionally behave the way we do right now. |
It is a common mistake to think There is a long description of the problem there: https://bugs.freedesktop.org/show_bug.cgi?id=105572#c1. pkg-config has no way to tell a dependency is internal and is needed only for static linking. |
Note that if you use shared_library() it will not add Requires.private, but when you use library() it will add Requires.private regardless of default_library option. That has been changed years ago and I'm still totally against that inconsistency, but it was a compromise for distro that were not happy to add extra useless dev dependencies. |
This is not mistake. Please one more time look on quoted documentation. subprojects/spice-common/meson.build:144:16: ERROR: Dependency lookup for libcacard with method 'pkgconfig' failed: Could not generate cargs for libcacard:
Package nss was not found in the pkg-config search path.
Perhaps you should add the directory containing `nss.pc'
to the PKG_CONFIG_PATH environment variable
Package 'nss', required by 'libcacard', not found
Package 'libpcsclite', required by 'libcacard', not found
A full log can be found at /home/tkloczko/rpmbuild/BUILD/spice-gtk-0.42/x86_64-redhat-linux-gnu/meson-logs/meson-log.txt Which does not make ANY sense. It is yet another issue in meson unittests/linuxliketests.py where is: cmd = [PKG_CONFIG, 'requires-test']
out = self._run(cmd + ['--print-requires'], override_envvars=env).strip().split('\n')
if not is_openbsd():
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo >= 1.0', 'libhello']))
else:
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo>=1.0', 'libhello']))
cmd = [PKG_CONFIG, 'requires-private-test']
out = self._run(cmd + ['--print-requires-private'], override_envvars=env).strip().split('\n')
if not is_openbsd():
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo >= 1.0', 'libhello']))
else:
self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo>=1.0', 'libhello'])) So exactly this part is causing that Requires and Requires.private are combined UNCINDITIOANLLY (no matter is project links statically od dynamically linked binaries). My understanding is that use IMO main reason why it is so inconsistently treated/combined is yer another issue in rpm pkgconfig generator where in checking packaged .pc files is used pkgconfig executed with In other words there are some other branches of hart inconsistency caused by rpm. |
And that is nothing more than only unnecessary/incorrect assumption. |
Meson has no way to know if nss and libpcsclite headers are exposed in libcacard headers. They very well could be needed even when building only shared libraries. It is a fundamental limitation of pkg-config, there is no way to tell of a dependency is only needed for static linking, or also needed for its headers. |
That means that libcacard does need a build-dep on nss and libpcsclite, even if it's not used at all. |
Additionally I can tell you that up to meson 1.0.0 I've been using patch which removed propagate By this in last 3-4 years I'v been able to catch only handful (less than 10) number of projects (on scale +5k of all packages in distribution) which was necessity to correct pkgconfig calls on finding dependencies. |
That's true and that's intentional. cflags (not libs) are always combined from Requires and Requires.private. That's how pkg-config works. For better or worse... |
EXACTLY!! 😄 |
A big part of the problem is pkg-config is unmaintained. I did propose to add I think the solution is;
|
That is not true. |
So .. because |
The doc is not wrong, it is incomplete. It should say in addition that cflags are always taken from Requires.private regardless of |
Hmm IMO that is 100% clear and complete. |
It tells about libraries, not cflags! That's the whole story here! |
Look .. only scenario which needs to handled is when project A is linked with libX and that library could be build as stared and/or static one. |
As I wrote already if libX used header files of libY it should be listed in Requires because no matter how project A will be linked against libX (statically or dynamically) libY header files will be used as well. |
In your specific case maybe, but that's not always the case, and Meson has no way to know.
|
That's wrong, you did not understand. There are cases you need headers from libX but not link to libX. |
In the link I posted, |
Control question: what is ANY other need to propagate libX build dependencies from libY especially on building project A than what I've described? If answer will be |
That would incorrectly over-link the shared libraries of those dependencies in cases where the headers are needed transitively but not the libraries directly. This was already explained to you, but you're not listening. |
More generally, the bug report is incorrect, and submitted by someone who often... misunderstands requirements. There's a real issue here, but it's not the one you reported, and it's one we have an existing ticket for -- plus one we know about quite well. This bug report has outlived its usefulness. |
Dummy example: liba.h
libb.h
app.c
=> app does not have to link to liba but it must have its header. liba is a build-dep not a runtime dep. |
Describe the bug
From https://people.freedesktop.org/~dbn/pkg-config-guide.html:
Scenario:
libfoo
build withlibrary(libfoo, 'foo': libfoo_src, dependencies: [ bar1_deps, bar2_deps], <other_args>)
libfoo
is generated pkgconfig file usingpc.generate(libfoo, libraries: libfoo, <other_params>)
meson -D default_library=shared
Generated libfoo.pc file will will have
Requires.private
field with libraries listed independencies: [ bar1_deps, bar2_deps]
.In this situation it does not make any sense because produced binaries will not contain static libraries.
To Reproduce
You can clone https://gitlab.freedesktop.org/spice/libcacard/ and add below patch (I just found that pc.generate() is wrongly defined) :
Without that patch generated libcacard.pc is without `Libs: entry')
Expected behavior
If library pkgconfig file is generated and only shared library is build
Requires.private
should not be added because product of the build will not possible to use for static linking.system parameters
meson --version
: 1.2.1ninja --version
N/AThe text was updated successfully, but these errors were encountered: