Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] full_deploy introduces erroneous relative includedir for xorg package #15242

Closed
spiderkeys opened this issue Dec 8, 2023 · 4 comments · Fixed by #15244
Closed

[bug] full_deploy introduces erroneous relative includedir for xorg package #15242

spiderkeys opened this issue Dec 8, 2023 · 4 comments · Fixed by #15244
Assignees
Milestone

Comments

@spiderkeys
Copy link

spiderkeys commented Dec 8, 2023

Environment details

  • Operating System+version: Ubuntu 22.04 , x86_64
  • Compiler+version: gcc-11
  • Conan version: 2.0.14
  • Python version: 3.10.12

I ran into a similar problem as in #14022 when trying to use full_deploy with a package that depended on xorg.

I was able to reproduce the issue by creating a near-exact copy of the xorg test_package and building it like it was a normal consuming application:

My conanfile.py:

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.cmake import CMakeDeps
from conan.tools.files import copy
from pprint import pprint
import os

class TestConan(ConanFile):
    name = "test_conan"
    settings    = "os", "compiler", "build_type", "arch"
    generators  = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv", "VirtualBuildEnv"
    
    def layout(self):
        cmake_layout(self)

    def requirements(self):
        self.requires( "xorg/system" )

    def generate(self):
        pprint( vars(self.dependencies["xorg"].cpp_info.components["uuid"]))
        

My cmake file:

cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

find_package(xorg REQUIRED CONFIG)

add_executable(test_package test_package.c)
target_link_libraries(test_package PRIVATE xorg::xorg)

My source file:

#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include <X11/Xauth.h>

#include <X11/SM/SMlib.h>

#include <stdio.h>

int main() {
    Display *display = XOpenDisplay(NULL);

    if (!display) {
        printf("XOpenDisplay failed\n");
        return 0;
    }

    {
        char *xau_file_name = XauFileName();
        if (xau_file_name)
            printf("XauFileName: %s\n", xau_file_name);
    }

    XCloseDisplay(display);
    SmcSetErrorHandler(NULL);
}

conan install command:

# from dir with conanfile.py and cmakelists.txt in it...
mkdir build && cd build
conan install .. --deployer=full_deploy -of .. -s build_type=Release --build=missing

cmake invocation:

cmake .. -DCMAKE_TOOLCHAIN_FILE=Release/generators/conan_toolchain.cmake  -DCMAKE_BUILD_TYPE=Release

Error output from cmake:

...
-- Conan: Target declared 'xorg::xorg'
-- Configuring done
CMake Error in CMakeLists.txt:
  Imported target "xorg::xorg" includes non-existent path

    "/home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/build/Release/generators/../../../full_deploy/host/xorg/system/../../../../../../../usr/include/uuid"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

Ultimately, the includedirs for the generated cmake support files end up with an erroneous relative path, similar to the linked vulkan issue at the beginning of my post:

########### COMPONENT xorg::uuid VARIABLES ############################################

set(xorg_xorg_uuid_INCLUDE_DIRS_RELEASE "${xorg_PACKAGE_FOLDER_RELEASE}/../../../../../../usr/include/uuid")

I confirm (with some pprint(vars()) calls of the uuid dependency in the xorg and consuming recipes) that the modification happens during the deploy->generation process of conan install:

======== Installing packages ========
xorg/system: Already installed! (1 of 1)
{'_bindirs': ['bin'],
 '_builddirs': None,
 '_cflags': [],
 '_cxxflags': [],
 '_defines': [],
 '_exelinkflags': [],
 '_frameworkdirs': None,
 '_frameworks': None,
 '_includedirs': ['/usr/include/uuid'],
 '_libdirs': [],
 '_libs': None,
 '_objects': None,
 '_properties': {'component_version': '2.37.2',
                 'pkg_config_custom_content': 'exec_prefix=/usr\n'
                                              'libdir=/usr/lib/x86_64-linux-gnu',
                 'pkg_config_name': 'uuid'},
 '_requires': None,
 '_resdirs': None,
 '_sharedlinkflags': [],
 '_srcdirs': None,
 '_sysroot': None,
 '_system_libs': ['uuid'],
 'build_modules': <conans.model.build_info.MockInfoProperty object at 0x7fe2e229dd20>,
 'filenames': <conans.model.build_info.MockInfoProperty object at 0x7fe2e229dc90>,
 'names': <conans.model.build_info.MockInfoProperty object at 0x7fe2e229da80>,
 'version': '2.37.2'}

In the generate step of the consumer:

def generate(self):
        pprint( vars(self.dependencies["xorg"].cpp_info.components["uuid"]))
======== Finalizing install (deploy, generators) ========
conanfile.py (test_conan/None): Conan built-in full deployer to /home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp
conanfile.py (test_conan/None): Writing generators to /home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/build/Release/generators
conanfile.py (test_conan/None): Generator 'VirtualRunEnv' calling 'generate()'
conanfile.py (test_conan/None): Generator 'CMakeToolchain' calling 'generate()'
conanfile.py (test_conan/None): CMakeToolchain generated: conan_toolchain.cmake
conanfile.py (test_conan/None): Preset 'conan-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-release' if using CMake>=3.23
conanfile.py (test_conan/None): If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/build/Release/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
conanfile.py (test_conan/None): CMakeToolchain generated: CMakePresets.json
conanfile.py (test_conan/None): CMakeToolchain generated: ../../../CMakeUserPresets.json
conanfile.py (test_conan/None): Generator 'CMakeDeps' calling 'generate()'
conanfile.py (test_conan/None): Generator 'VirtualBuildEnv' calling 'generate()'
conanfile.py (test_conan/None): Calling generate()
conanfile.py (test_conan/None): Generators folder: /home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/build/Release/generators
{'_bindirs': ['/home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/full_deploy/host/xorg/system/bin'],
 '_builddirs': [],
 '_cflags': [],
 '_cxxflags': [],
 '_defines': [],
 '_exelinkflags': [],
 '_frameworkdirs': [],
 '_frameworks': [],
 '_includedirs': ['/home/spiderkeys/z/mr/git/mr-conan-index/temp/installtemp/full_deploy/host/xorg/system/../../../../../../../usr/include/uuid'],

(see last lines above)

It seems like something weird is happening with the uuid dependency of xorg in the full_deploy deployer, maybe relating to the fact that it is a system dependency, not sure. There was no modification to the xorg recipe I could make which fixed the issue besides removing uuid from the package_info() method (which broke xorg's tests, but allowed my consuming application to config cmake properly)

@memsharded memsharded self-assigned this Dec 9, 2023
@memsharded memsharded added this to the 2.0.15 milestone Dec 9, 2023
@memsharded
Copy link
Member

Hi @spiderkeys

thanks very much for reporting.

It seems that the deployers are relativizing absolute paths (those that happens in system packages), while they should be left as-is.

I am proposing a potential fix in #15244, if you want to give it a try running from source, that would be good feedback too

@memsharded
Copy link
Member

#15244 has been merged for next 2.0.15, feedback still welcome if you can give it a try.

@spiderkeys
Copy link
Author

Hi, sorry for the slow followup. I tested with 2.0.15-dev and the issue was resolved. Thanks!

@memsharded
Copy link
Member

Excellent, thanks for the feedback!
We are aiming at releasing it soon, hopefully tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants