Skip to content

[bug] conan does not set env variables from profile [buildenv] in package_info, which leads to pkg-config issues #18128

Closed
@qwertzui11

Description

@qwertzui11

Describe the bug

Hi! Let me start of by saying thanks for your great work with conan.

My current goal is to setup a hello-world qt project for arm64v8.
The OS-Team gave me a nice toolchain to compile for the arm64v8 platform.

BuildOS: ubuntu24.04
conan-version: 2.15.0

How to reproduce it

I got the following conanfile.py created by conan new cmake_exe -d name=foo -d version=1.0

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps


class fooRecipe(ConanFile):
    name = "foo"
    version = "1.0"
    package_type = "application"

    # Optional metadata
    license = "<Put the package license here>"
    author = "<Put your name here> <And your email here>"
    url = "<Package recipe repository url here, for issues about the package>"
    description = "<Description of foo package here>"
    topics = ("<Put some tag here>", "<here>", "<and here>")

    # Binary configuration
    settings = "os", "compiler", "build_type", "arch"

    # Sources are located in the same place as this recipe, copy them to the recipe
    exports_sources = "CMakeLists.txt", "src/*"

    def requirements(self):
        # the goal is to use qt
        # self.requires("qt/6.7.3")
        # the problem arises with
        self.requires("opengl/system")

    def layout(self):
        cmake_layout(self)

    def generate(self):
        deps = CMakeDeps(self)
        deps.generate()
        tc = CMakeToolchain(self)
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()

Using conan install

conan install \
  --profile:build default \
  --profile:host ./tools/conan-profiles/arm64v8-toolchain \
  --remote conancenter \
  --build missing \
  -s build_type=Release \
  .

with the host profile

{% set sysroots_path = os.getenv("SYSROOTS_PATH") %}

[settings]
os=Linux
arch=armv8
compiler=gcc
build_type=Release
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11

[buildenv]
#CC={{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
#CXX={{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++
#LD={{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-ld

PKG_CONFIG_PATH+=(path){{ sysroots_path }}/armv8a-poky-linux/usr/lib/pkgconfig
PKG_CONFIG_PATH+=(path){{ sysroots_path }}/armv8a-poky-linux/usr/share/pkgconfig
PKG_CONFIG_SYSROOT_DIR=(path){{ sysroots_path }}/armv8a-poky-linux
CMAKE_CROSSCOMPILING_EMULATOR={{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/qemu-aarch64;-L;{{ sysroots_path }}/armv8a-poky-linux/

[conf]
tools.build:sysroot={{ sysroots_path }}/armv8a-poky-linux/
tools.build:compiler_executables={"c":"{{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc","cpp":"{{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++"}
tools.gnu:pkg_config={{ sysroots_path }}/x86_64-pokysdk-linux/usr/bin/pkg-config
tools.system.package_manager:mode=report-installed

tools.cmake.cmaketoolchain:system_name="Linux"
tools.cmake.cmaketoolchain:system_processor="aarch64"

Results in the following error log

======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
[replace_requires]
libmount/2.39.2: libmount/2.40.2
[conf]
core.cache:storage_path=/mnt/work/conan
tools.build:compiler_executables={'c': '/mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g
cc', 'cpp': '/mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++'}
tools.build:sysroot=/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/
tools.cmake.cmaketoolchain:system_name="Linux"
tools.cmake.cmaketoolchain:system_processor="aarch64"
tools.gnu:pkg_config=/mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-config
tools.system.package_manager:mode=report-installed
[buildenv]
PKG_CONFIG_PATH+=(path)/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/usr/lib/pkgconfig
PKG_CONFIG_PATH+=(path)/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/usr/share/pkgconfig
PKG_CONFIG_SYSROOT_DIR=(path)/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux
CMAKE_CROSSCOMPILING_EMULATOR=/mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-aarch64;-L;/mnt/work/Development/conan-fun/
toolchain/sysroots/armv8a-poky-linux/

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
[conf]
core.cache:storage_path=/mnt/work/conan
tools.system.package_manager:mode=install
tools.system.package_manager:sudo=True


======== Computing dependency graph ========
Graph root
    conanfile.py (foo/1.0): /mnt/work/Development/conan-fun/conanfile.py
Requirements
    opengl/system#7c02ea6ef926fd04844af53622a30541 - Cache

======== Computing necessary packages ========
Requirements
    opengl/system#7c02ea6ef926fd04844af53622a30541:da39a3ee5e6b4b0d3255bfef95601890afd80709#0ba8627bd47edc3a501e8f0eb9a79e5e - Cache
dpkg-query: no packages found matching libgl-dev:arm64

======== Installing packages ========
opengl/system: Already installed! (1 of 1)
ERROR: opengl/system: Error in package_info() method, line 68
        pkg_config.fill_cpp_info(self.cpp_info, is_system=self.settings.os != "FreeBSD")
        ConanException: PkgConfig failed. Command: /mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-config --print-provides 
gl --print-errors
    stdout:

    stderr:
    Package gl was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gl.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gl' found

The thing is, that /mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/usr/lib/pkgconfig contains the gl.pc.

I can verify it by using all the values from the conan logs:

export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/usr/lib/pkgconfig"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/mnt/work/Development/conan-fun/toolchain/sysroots/armv8a-poky-linux/usr/share/pkgconfig"
/mnt/work/Development/conan-fun/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-config --print-provides gl --print-errors

gives gl = 1.2. Without the environment variables PKG_CONFIG_PATH I get the same error like conan.

So I assume there is an issue with conan in package_info not setting the environment variables given by the [buildenv] profile.
The PKG_CONFIG_PATH works nicely in other contexts with conan.
What do you think?

Thanks for your time! :)
Cheers

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions