question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Conan doesn't re-configure the test_package when using the new conan.tools.cmake helper

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 20.04
  • Compiler+version: Gcc8
  • Conan version: 1.53.0
  • Python version: 3.8

I’m trying to compile the opengv recipe which has been recently modernized to support both the test_package and the test_v1_package. I’d expect Conan to use the test_v1_package since I’m in conan 1.53, but that’s not the case. So maybe I’m doing something wrong or maybe there is something wrong on the recipe. Anyways, I’ve noticed that conan doesn’t delete the build folder under test_package before trying to build nor does it force a CMake re-configure, so if there is a previous build folder (CMake project) conan will reuse that which is problematic. Particularly if you build a package for x86 and after that you try to crosscompile (or target any different arch). An example may clarify this. I’ll be using conan test for simplicity, but conan create behaves the same way.

I’ll start by testing the aarch64 version of the package, I’ve manually nuked test_package/build.:

$ conan test recipes/opengv/all/test_package opengv/cci.20200806@asd/asd -pr:b .conanprofiles/x86_64_gcc8 -pr:h .conanprofiles/aarch64     
Configuration (profile_host):
[settings]
arch=aarch64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.sdkversion=SDK/aarch64-1.3@eriff/stable
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
*: SDK/aarch64-1.3@eriff/stable
[env]
CHOST=aarch64-oe-linux
CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
CONAN_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
CPATH=[/home/eriff/conan/.conanprofiles/../irstd/include]
Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
CPATH=[/home/eriff/conan/.conanprofiles/../irstd/include]
opengv/cci.20200806@asd/asd (test package): Installing package
Requirements
    eigen/3.4.0 from 'conancenter' - Cache
    opengv/cci.20200806@asd/asd from local cache - Cache
Packages
    eigen/3.4.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
    opengv/cci.20200806@asd/asd:4ac968e63c52efebbf04bf21cce4e09a2e311089 - Cache
Build requirements
    SDK/aarch64-1.3@eriff/stable from 'conan-eriff' - Cache
Build requirements packages
    SDK/aarch64-1.3@eriff/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache

Cross-build from 'Linux:x86_64' to 'Linux:aarch64'
Installing (downloading, building) binaries...
SDK/aarch64-1.3@eriff/stable: Already installed!
eigen/3.4.0: Already installed!
opengv/cci.20200806@asd/asd: Already installed!
opengv/cci.20200806@asd/asd (test package): Applying build-requirement: SDK/aarch64-1.3@eriff/stable
opengv/cci.20200806@asd/asd (test package): Generator txt created conanbuildinfo.txt
opengv/cci.20200806@asd/asd (test package): Generator 'CMakeToolchain' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
opengv/cci.20200806@asd/asd (test package): If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
opengv/cci.20200806@asd/asd (test package): Generator 'CMakeDeps' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Generator 'VirtualRunEnv' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Aggregating env generators
opengv/cci.20200806@asd/asd (test package): Generated conaninfo.txt
opengv/cci.20200806@asd/asd (test package): Generated graphinfo
Using lockfile: '/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan.lock'
Using cached profile from lockfile
opengv/cci.20200806@asd/asd (test package): Calling build()
opengv/cci.20200806@asd/asd (test package): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/eriff/conan/recipes/opengv/all/test_package/."
-- Using Conan toolchain: /home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake
-- The CXX compiler identification is GNU 8.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/eriff/.conan/data/SDK/aarch64-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Target declared 'opengv'
-- Conan: Component target declared 'Eigen3::Eigen'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/eriff/conan/recipes/opengv/all/test_package/build/Release
opengv/cci.20200806@asd/asd (test package): CMake command: cmake --build "/home/eriff/conan/recipes/opengv/all/test_package/build/Release" '--' '-j12'
[ 50%] Building CXX object CMakeFiles/test_package.dir/test_package.cpp.o
[100%] Linking CXX executable test_package
[100%] Built target test_package
opengv/cci.20200806@asd/asd (test package): Running test()

This passes as expected. Now I’ll test the x86 version of the package. The linker will fail because conan will not delete the previous test_package/build folder and therefore it will reuse the CMakeCache from the previous build.

$ conan test recipes/opengv/all/test_package opengv/cci.20200806@asd/asd -pr:b .conanprofiles/x86_64_gcc8 -pr:h .conanprofiles/x86_64_gcc8
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

opengv/cci.20200806@asd/asd (test package): Installing package
Requirements
    eigen/3.4.0 from 'conancenter' - Cache
    opengv/cci.20200806@asd/asd from local cache - Cache
Packages
    eigen/3.4.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
    opengv/cci.20200806@asd/asd:cce2da5111e98f1e6837abae08db0ea4f12b7aa4 - Cache

Installing (downloading, building) binaries...
eigen/3.4.0: Already installed!
opengv/cci.20200806@asd/asd: Already installed!
opengv/cci.20200806@asd/asd (test package): Generator 'CMakeDeps' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Generator 'VirtualRunEnv' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Generator txt created conanbuildinfo.txt
opengv/cci.20200806@asd/asd (test package): Generator 'CMakeToolchain' calling 'generate()'
opengv/cci.20200806@asd/asd (test package): Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
opengv/cci.20200806@asd/asd (test package): If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
opengv/cci.20200806@asd/asd (test package): Aggregating env generators
opengv/cci.20200806@asd/asd (test package): Generated conaninfo.txt
opengv/cci.20200806@asd/asd (test package): Generated graphinfo
Using lockfile: '/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan.lock'
Using cached profile from lockfile
opengv/cci.20200806@asd/asd (test package): Calling build()
opengv/cci.20200806@asd/asd (test package): CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/eriff/conan/recipes/opengv/all/test_package/."
-- Using Conan toolchain: /home/eriff/conan/recipes/opengv/all/test_package/build/generators/conan_toolchain.cmake
-- Conan: Target declared 'opengv'
-- Conan: Component target declared 'Eigen3::Eigen'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/eriff/conan/recipes/opengv/all/test_package/build/Release
opengv/cci.20200806@asd/asd (test package): CMake command: cmake --build "/home/eriff/conan/recipes/opengv/all/test_package/build/Release" '--' '-j12'
Consolidate compiler generated dependencies of target test_package
[ 50%] Building CXX object CMakeFiles/test_package.dir/test_package.cpp.o
[100%] Linking CXX executable test_package
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a(roots.cpp.o): Relocations in generic ELF (EM: 62)
/home/eriff/.conan/data/SDK/qcs40x-1.3/eriff/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/8.2.0/real-ld: /home/eriff/.conan/data/opengv/cci.20200806/asd/asd/package/cce2da5111e98f1e6837abae08db0ea4f12b7aa4/lib/libopengv.a: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/test_package.dir/build.make:98: test_package] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_package.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
ERROR: opengv/cci.20200806@asd/asd (test package): Error in build() method, line 21
	cmake.build()
	ConanException: Error 2 while executing cmake --build "/home/eriff/conan/recipes/opengv/all/test_package/build/Release" '--' '-j12'

The same happens if I test the arm32 package after that. But If I rm -rf recipes/opengv/all/test_package/build then test package passes as expected.

This is not an issue with the old helpers, aka the ones used on test_v1_package since they create subfolders inside of the build folder.

ls -la recipes/opengv/all/test_v1_package/build 
total 16
drwxrwxr-x 4 eriff eriff 4096 oct 12 15:00 .
drwxrwxr-x 3 eriff eriff 4096 oct 12 15:00 ..
drwxrwxr-x 4 eriff eriff 4096 oct 12 15:00 03c51f6c911d54064d2abf035cf599e7e833cebf
drwxrwxr-x 4 eriff eriff 4096 oct 12 15:00 19b84d7ca024c7194850f6ff6464450c4e27e01a

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Oct 12, 2022

I think it is fine to close it, as it is already fixed in released 2.0, and we are closing tickets when they are fixed, annotating the release.

1reaction
memshardedcommented, Oct 12, 2022

The -tf=test_v1_package can always be defined to use that test_package folder instead

Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] cmake generator does not write build requirements info ...
The generated conanbuildinfo.cmake does not contain doctest targets, but it does when conan install . --profile=default is used.
Read more >
Changelog — conan 1.36.0 documentation
Docs here; Bugfix: Fixed test_package/conanfile.py using build_requires for ... and new CMake experimental helpers to the new from conan.tools.cmake import.
Read more >
How to choose Ninja as CMake generator with Conan?
They are incompatible. You can keep the new helper, but you need to define your generator in conanbuild.conf . (Yet not documented).
Read more >
Conan package manager tutorial - Level Up Coding
In this post, I give a short introduction of Conan package ... become the de facto tool for C/C++ packages, I focus on...
Read more >
Testing With CMake and CTest
Testing is a key tool for producing and maintaining robust, valid software. ... Regression testing verifies that the results of a test do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found