Re: [RFC] meson needs a pkg-config wrapper script

Alexander Kanavin

Please keep the conversation on the list.

Those are two different, independently developed projects:
and they are not fully compatible as you have just shown.

I'm not sure how pkgconf is able to decide that includedir is a path (short of hardcoding that inside the source somewhere), but such logic needs to be carefully investigated before we make use of it, e.g. by switching to pkgconf in oe-core.


On Wed, 1 Dec 2021 at 23:31, Joel Winarske <joel.winarske@...> wrote:
pkg-config --version ?

Using 0.29.2 I get the same output as you:
$ PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET /home/linuxbrew/.linuxbrew/bin/pkg-config --define-variable=prefix=/opt --variable=includedir glesv2

Using 1.7.3 it works:
PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET /usr/bin/pkg-config --variable=includedir glesv2

$ /usr/bin/pkg-config --version

$ /home/linuxbrew/.linuxbrew/bin/pkg-config --version

On Wed, Dec 1, 2021 at 12:36 AM Alexander Kanavin <alex.kanavin@...> wrote:
No, it's not that. Even if you pass PKG_CONFIG_SYSROOT_DIR to pkg-config directly, it will apply that only to --cflags and similar, but not to generic --variable. Try this:

alex@alex-lx-laptop:~$ PKG_CONFIG_SYSROOT_DIR=/aaaa pkg-config libdrm --cflags
alex@alex-lx-laptop:~$ PKG_CONFIG_SYSROOT_DIR=/aaaa pkg-config libdrm --variable=includedir

So a wrapper will not solve the 'includedir prefix' problem, and neither the wrapper, nor pkg-config or meson can possibly know which variable is a path, and which isn't - the only place where that is known is the component that obtains the variable. And so that's where it has to be prefixed.


On Tue, 30 Nov 2021 at 23:38, Joel Winarske <joel.winarske@...> wrote:
Based on my testing, if PKG_CONFIG_SYSROOT_DIR is set or not makes zero difference on the outcome.  I suspect this is related to how pkg-config is launched by meson.

Looking at the meson source tree, in all ci/test cross compile scenarios they reference a pkg-config wrapper.  No cross compile scenario I see referencing the 'pkgconfig' key uses a bare pkg-config.

    cross/armclang-linux.txt:#pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'
    cross/linux-mingw-w64-32bit.txt:pkgconfig = '/usr/bin/i686-w64-mingw32-pkg-config'
    cross/linux-mingw-w64-64bit.txt:pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
    cross/ubuntu-armhf.txt:pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'
    test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt:pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config'
    test cases/unit/36 exe_wrapper behaviour/broken-cross.txt:pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'

I think adding a wrapper makes sense.

On Tue, Nov 30, 2021 at 12:13 PM Alexander Kanavin <alex.kanavin@...> wrote:
On Tue, 30 Nov 2021 at 21:00, Joel Winarske <joel.winarske@...> wrote:
Yes, if the sys_root key value in meson.cross is present PKG_CONFIG_SYSROOT_DIR gets set.  Honister patch I confirmed with:

The issue is that meson doesn't pass PKG_CONFIG_SYSROOT_DIR to the shell environment that runs pkg-config, as with the pkg-config sandbox test it does work.

Both meson source code and its documentation indicate otherwise - if you set sys_root property, it will get passed to pkg-config via environment as PKG_CONFIG_SYSROOT_DIR:


Join { to automatically receive all group messages.