Skip to content
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

pkg-config path used in dependency(..., native:true) is sometimes incorrect #1736

Closed
ghost opened this issue May 4, 2017 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented May 4, 2017

I have found that when doing cross compilation if you first call host dependency() and then dependency(native: true), then dependency(native: true) will use pkg-config path that is used (and cached) by dependency().

When I change the order, everything is ok. There's some caching of pkg-config paths going on, and in this specific case, it goes wrong.

@nirbheek
Copy link
Member

nirbheek commented May 6, 2017

This is another bug in the caching of dependencies. It's easy to fix it. Will provide a patch.

@ghost
Copy link
Author

ghost commented Jul 24, 2018

This needs to be re-open, because it is still broken.

@ghost
Copy link
Author

ghost commented Jul 24, 2018

This patch fixes the issue (stop cachig cross pkg-config into the same var that later can get used to fetch the native pkg-config incorrectly):

diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 864fd736..b14d8c6b 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -448,7 +448,6 @@ class PkgConfigDependency(ExternalDependency):
                 potential_pkgbin = ExternalProgram.from_cross_info(environment.cross_info, 'pkgconfig')
                 if potential_pkgbin.found():
                     self.pkgbin = potential_pkgbin
-                    PkgConfigDependency.class_pkgbin = self.pkgbin
                 else:
                     mlog.debug('Cross pkg-config %s not found.' % potential_pkgbin.name)
         # Only search for the native pkg-config the first time and

@ghost ghost mentioned this issue Jul 29, 2018
@nirbheek nirbheek reopened this Jul 29, 2018
@nirbheek nirbheek added this to the 0.48.0 milestone Jul 29, 2018
@nirbheek nirbheek modified the milestones: 0.48.0, 0.47.2 Aug 7, 2018
atweiden pushed a commit to atweiden/voidpkgs that referenced this issue Sep 10, 2018
void-linux/void-packages@d642a54

Allows us to use the PKG_CONFIG variable to tell Meson which is the
pkg-config to be used to get our native dependencies.

We actually could always do that but Meson would cache the variable for
the pkg-config file if we used the dependency() call without 'native:
true' and after that all future usages of dependency() even with
'native: true' would use the cross-compile one.

See this issue from where the patch came from:

- mesonbuild/meson#1736
atweiden pushed a commit to atweiden/voidpkgs that referenced this issue Sep 10, 2018
void-linux/void-packages@d056217

PKG_CONFIG environment variable should point to the pkg-config executable
to be used to fetch dependencies that use 'native: true' (indicate to build
against host libraries not cross-compiled ones)

To meet those requirements we set an absolute path to the host
pkg-config since the relative path to pkg-config is taken by the
wrapper.

This currently requires a patch that is a milestone of meson-0.48 that
was generated by the issue:

mesonbuild/meson#1736
@nirbheek nirbheek modified the milestones: 0.48.0, 0.49.0 Sep 20, 2018
@ghost
Copy link
Author

ghost commented Nov 5, 2018

Can we please get this fixed? Here's a test case and a fix, please pull:

https://megous.com/git/meson/log/?h=issue-1736

Test cases depend on the presence of the cross-compiled zlib and someone not using --prefix=/usr for cross build. It's impossible to test this without a predefined (cross-build) test environment, but it's pretty clear what's going wrong from the code itself. So skip the tests if you like, but please apply the fix, so that people don't have to carry around patches for meson.

Thanks!

@ghost
Copy link
Author

ghost commented Nov 8, 2018

Seems like someone with commit rights independently fixed it in 11e3011 with the exact same fix, so this can be closed.

@ghost ghost closed this as completed Nov 8, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant