Skip to content

[bug] MesonToolchain does not create pkg-config entry in native file when crosscompiling #19214

@planetmarshall

Description

@planetmarshall

Describe the bug

Underlying cause of conan-io/conan-center-index#28861

When generating the meson configuration files with MesonToolchain(native=True), the native file does not contain the binaries for pkgconf where they have been specified in the build requirements. These are necessary to crosscompile a Meson project which depends on native binaries. For example, see conan-io/conan-center-index#28663

How to reproduce it

conan-io/conan-center-index#28663 reproduces the issue and conan-io/conan-center-index#28861 has further information.

Additionally, using the following recipe:

from conan import ConanFile
from conan.tools.meson import MesonToolchain
from conan.tools.env import VirtualBuildEnv 
from conan.tools.build import cross_building


class TestConan(ConanFile):
    name = "test"
    settings = "os", "arch", "compiler", "build_type"

    def build_requirements(self):
        self.tool_requires("meson/[>=1.4.0 <2]")
        self.tool_requires("pkgconf/[>=2.2 <3]")

    def generate(self):
        VirtualBuildEnv(self).generate()

        MesonToolchain(self).generate()

        if cross_building(self):
            MesonToolchain(self, native=True).generate()

Using the profiles build and host respectively -

[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu20
compiler.cstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=15
os=Linux
[settings]
arch=armv7hf
build_type=Release
compiler=gcc
compiler.cppstd=gnu20
compiler.cstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=15
os=Linux
conan install . --profile:build=build --profile:host=host --build=missing

Then examine the generated conan_meson_native.ini file. It does not contain the required pkg-config entry in [binaries] (it is contained in the conan_meson_cross.ini file, but this is not used when Meson is asked to find native binaries in a cross compilation context).

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions