diff options
author | Lyude Paul <lyude@redhat.com> | 2018-11-04 15:08:20 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-11-06 21:12:10 +0200 |
commit | 11e3011a6bf0adeb51582c590c90b0f4dccb4df8 (patch) | |
tree | 082c8df7390e5c8b723603e335a72ef08feaf895 /test cases/unit | |
parent | d178fd0ab333434bec92553f2ad16b0835360a44 (diff) | |
download | meson-11e3011a6bf0adeb51582c590c90b0f4dccb4df8.zip meson-11e3011a6bf0adeb51582c590c90b0f4dccb4df8.tar.gz meson-11e3011a6bf0adeb51582c590c90b0f4dccb4df8.tar.bz2 |
Don't use host pkg-config for native dependencies
When trying to cross-compile mesa on an aarch64 system, I noticed some
strange behavior. Meson would only ever find the wayland-scanner binary
in my host machine's sysroot (/mnt/amethyst):
Native dependency wayland-scanner found: YES 1.16.0
Program /mnt/amethyst/usr/bin/wayland-scanner found: YES (/mnt/amethyst/usr/bin/wayland-scanner)
It should be finding /usr/bin/wayland-scanner instead, since the
wayland-scanner dependency is created as native. On closer inspection,
it turned out that meson was ignoring the native argument passed to
dependency(), and wuld always use the pkgconfig binary specified in my
toolchain instead of the native one (/usr/bin/pkg-config):
Native dependency wayland-scanner found: YES 1.16.0
Called `/home/lyudess/Projects/panfrost/scripts/amethyst-pkg-config
--variable=wayland_scanner wayland-scanner` -> 0
Turns out that if we create a dependency() object with native:false, we
end up caching the pkg-config path for the host machine in
PkgConfigDependency.class_pkgbin, instead of the build machine's
pkg-config path. This results causing in all pkg-config invocations for
dependency() objects to use the host machine's pkg-config binary,
regardless of whether or not 'native: true' was specified when the
dependency() object was instantiated.
So, fix this by never setting PkgConfigDependency.class_pkgbin for cross
dependency() objects. Also, add some test cases for this. Since
triggering this bug can be avoided by creating a dependency() objects
with native:true before creating any with native:false, we make sure
that our test has two modes: one where it starts with a native
dependency first, and another where it starts with a cross dependency
first.
As a final note here: We currently skip this test on windows, because
windows doesn't support directly executing python scripts as
executables: something that we need in order to point pkgconfig to a
wrapper script that sets the PKG_CONFIG_LIBDIR env appropriately before
calling pkg-config.
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Diffstat (limited to 'test cases/unit')
5 files changed, 43 insertions, 0 deletions
diff --git a/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py b/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py new file mode 100755 index 0000000..f0d89ee --- /dev/null +++ b/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +environ = os.environ.copy() +environ['PKG_CONFIG_LIBDIR'] = os.path.join( + os.path.dirname(os.path.realpath(__file__)), 'cross_pkgconfig') + +sys.exit( + subprocess.run(['pkg-config'] + sys.argv[1:], env=environ).returncode) diff --git a/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc b/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc new file mode 100644 index 0000000..67d7afa --- /dev/null +++ b/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc @@ -0,0 +1,5 @@ +dep_type=cross + +Name: dependency() test +Description: dependency() test +Version: 0 diff --git a/test cases/unit/46 native dep pkgconfig var/meson.build b/test cases/unit/46 native dep pkgconfig var/meson.build new file mode 100644 index 0000000..d95dbcd --- /dev/null +++ b/test cases/unit/46 native dep pkgconfig var/meson.build @@ -0,0 +1,15 @@ +project('native dep pkgconfig test') + +if get_option('start_native') + dep_native = dependency('dep_tester', native: true, method: 'pkg-config') + dep_cross = dependency('dep_tester', native: false, method: 'pkg-config') +else + dep_cross = dependency('dep_tester', native: false, method: 'pkg-config') + dep_native = dependency('dep_tester', native: true, method: 'pkg-config') +endif + +dep_type = dep_native.get_pkgconfig_variable('dep_type') +assert(dep_type == 'native', 'Expected native') + +dep_type = dep_cross.get_pkgconfig_variable('dep_type') +assert(dep_type == 'cross', 'Expected cross') diff --git a/test cases/unit/46 native dep pkgconfig var/meson_options.txt b/test cases/unit/46 native dep pkgconfig var/meson_options.txt new file mode 100644 index 0000000..37006dd --- /dev/null +++ b/test cases/unit/46 native dep pkgconfig var/meson_options.txt @@ -0,0 +1,6 @@ +option( + 'start_native', + type : 'boolean', + value : 'false', + description : 'Start by creating a dependency() with native : true', +) diff --git a/test cases/unit/46 native dep pkgconfig var/native_pkgconfig/dep_tester.pc b/test cases/unit/46 native dep pkgconfig var/native_pkgconfig/dep_tester.pc new file mode 100644 index 0000000..affaa97 --- /dev/null +++ b/test cases/unit/46 native dep pkgconfig var/native_pkgconfig/dep_tester.pc @@ -0,0 +1,5 @@ +dep_type=native + +Name: dependency() test +Description: dependency() test +Version: 0 |