meson/mesonbuild
Lyude Paul 11e3011a6b 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>
2018-11-06 21:12:10 +02:00
..
backend Accomodate clang-cl /showIncludes output 2018-11-04 15:42:06 +00:00
compilers Use lld-link with clang-cl 2018-11-04 15:42:06 +00:00
dependencies Don't use host pkg-config for native dependencies 2018-11-06 21:12:10 +02:00
modules gnome: Require GObject-Introspection 1.58.1 for static libraries 2018-11-06 13:09:32 -05:00
scripts depfixer: Do not try to fix rpaths of dlls 2018-10-25 19:30:02 +03:00
wrap wrap: Check the directory key is a name and not a path 2018-10-27 16:36:01 +03:00
__init__.py Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00
astinterpreter.py cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
build.py Detect clang-cl as msvc-like, not clang-like 2018-11-04 15:42:00 +00:00
coredata.py Expose wrap_mode as an option. Closes #4266. 2018-10-07 22:52:54 +03:00
environment.py Begin to factor out logic for getting binaries 2018-11-06 21:06:50 +02:00
interpreter.py Only add link arguments when needed in Compiler object methods 2018-11-04 15:42:06 +00:00
interpreterbase.py Make string division do path joining. 2018-11-02 21:02:25 +02:00
linkers.py D: Fix incorrect arch handling in D linkers 2018-09-20 19:00:12 +03:00
mconf.py Use a single ArgumentParser for all subcommands 2018-10-04 09:40:21 -04:00
mesonlib.py meson: performance optimizethe file object 2018-11-02 21:04:13 +02:00
mesonmain.py Hide 'rewrite' and 'runpython' commands from help 2018-10-04 09:40:21 -04:00
minit.py Use a single ArgumentParser for all subcommands 2018-10-04 09:40:21 -04:00
minstall.py Fix flake8 'imported but unused' reports 2018-10-24 19:11:46 +03:00
mintro.py Use a single ArgumentParser for all subcommands 2018-10-04 09:40:21 -04:00
mlog.py Print dependencies being used for compiler checks 2018-10-29 21:44:46 +02:00
mparser.py Interpreter: Add 'continue' and 'break' keywords 2018-10-04 20:14:37 -04:00
msetup.py msetup: Remove dead code 2018-10-17 21:56:49 -04:00
mtest.py test: do not use PIPE 2018-11-04 18:46:50 +02:00
optinterpreter.py UserFeatureOption: Default to 'auto' when no value specified 2018-07-25 09:55:16 -04:00
rewriter.py Use a single ArgumentParser for all subcommands 2018-10-04 09:40:21 -04:00