mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.6k stars 1.63k forks source link

pkg-config versus pkgconfig behavior #9674

Open jwinarske opened 2 years ago

jwinarske commented 2 years ago

Discussed in https://github.com/mesonbuild/meson/discussions/9673

Originally posted by **jwinarske** November 29, 2021 When detecting Vulkan dependency in cross compile case (Yocto) what is the proper pattern for deriving the absolute includedir? I'm doing this: ``` vulkan_dep = dependency('vulkan') vulkan_hpp = join_paths([ vulkan_dep.get_pkgconfig_variable('includedir'), 'vulkan', 'vulkan.hpp' ]) ``` How do I get sysroot to affect this, as I always end up with `/usr/include/vulkan/vulkan.hpp`.

PKGCONFIG* variables are not being exposed to pkg-config.

jwinarske commented 2 years ago

https://github.com/KhronosGroup/Vulkan-Loader/pull/756

jwinarske commented 2 years ago

A work around could be to have Yocto meson.bbclass generate a wrapper script similar to Example 4.4 in this link: https://autotools.io/pkgconfig/cross-compiling.html

As Yocto currently points to bare pkg-config, and PKG_CONFIG_SYSROOT_DIR is ignored.

Regardless of the potential workaround, meson should properly honor/pass PKG_CONFIG* variables to pkg-config.

jwinarske commented 2 years ago

Narrowed down pkg-config versus pkgconfig behavior. Yocto currently uses pkg-config for building.

STAGING_DIR_TARGET=/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot

Using pkgconfig 0.29.2

$ PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET /home/linuxbrew/.linuxbrew/bin/pkg-config --variable=includedir glesv2
/usr/include

Using pkg-config 1.7.3

PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET /usr/bin/pkg-config --variable=includedir glesv2
/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot/usr/include

https://gitlab.freedesktop.org/pkg-config/pkg-config https://github.com/pkgconf/pkgconf

What flavor is used for meson cross compilation validation?

eli-schwartz commented 2 years ago

So this works correctly if you use pkgconf, and it is broken if you use the freedesktop pkg-config?

jwinarske commented 2 years ago

I just confirmed Yocto is using pkg-config.

I haven't isolated between the two yet. Behavior difference was just discovered today.

jwinarske commented 2 years ago

That said I would only expect the freedesktop flavor to work correctly based on example above, as the pkgconf flavor ignores PKG_CONFIG_SYSROOT_DIR.