conan: [bug] Cross build from Linux x86_64 to Linux armv8 fails
Since I updated conan to version 1.31.3, I am not able to cross compile from amd64 to arm64 any more. I tracked it down to #7827 (https://github.com/conan-io/conan/pull/7827/files/5939976a86ac42055d79fe1abbe951b7c90daa13). When I revert the changes made in cmake_flags.py the build is working again. I’m still not sure about the underlying problem, but it seems to be related to the sysroot path.
Environment Details
- Operating System+version: Debian GNU/Linux bullseye/sid
- Compiler+version: aarch64-linux-gnu-gcc (Debian 10.2.0-9) 10.2.0
- Conan version: 1.30.1 (or above)
- Python version: 3.8
Profile
toolchain=aarch64-linux-gnu
[env]
CONAN_CMAKE_FIND_ROOT_PATH=/usr/$toolchain
CHOST=$toolchain
AR=$toolchain-ar
AS=$toolchain-as
RANLIB=$toolchain-ranlib
CC=$toolchain-gcc
CXX=$toolchain-g++
STRIP=$toolchain-strip
RC=$toolchain-windres
PKG_CONFIG_PATH=/usr/lib/$toolchain/pkgconfig
[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=x86_64
compiler=gcc
compiler.version=10
compiler.libcxx=libstdc++11
build_type=Release
Logs (Executed commands with output)
conan build ..
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc - broken
CMake Error at /usr/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/bin/aarch64-linux-gnu-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/martin/git/m100-common-lib/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake cmTC_0ca60/fast && /usr/bin/gmake -f CMakeFiles/cmTC_0ca60.dir/build.make CMakeFiles/cmTC_0ca60.dir/build
gmake[1]: Entering directory '/home/martin/git/m100-common-lib/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0ca60.dir/testCCompiler.c.o
/usr/bin/aarch64-linux-gnu-gcc --sysroot=/usr/aarch64-linux-gnu -o CMakeFiles/cmTC_0ca60.dir/testCCompiler.c.o -c /home/martin/git/m100-common-lib/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_0ca60
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0ca60.dir/link.txt --verbose=1
/usr/bin/aarch64-linux-gnu-gcc --sysroot=/usr/aarch64-linux-gnu CMakeFiles/cmTC_0ca60.dir/testCCompiler.c.o -o cmTC_0ca60
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: cannot find /usr/aarch64-linux-gnu/lib/libc.so.6 inside /usr/aarch64-linux-gnu
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: cannot find /usr/aarch64-linux-gnu/lib/libc_nonshared.a inside /usr/aarch64-linux-gnu
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: cannot find /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 inside /usr/aarch64-linux-gnu
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_0ca60.dir/build.make:106: cmTC_0ca60] Error 1
gmake[1]: Leaving directory '/home/martin/git/m100-common-lib/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_0ca60/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (17 by maintainers)
At the moment I can’t quickly switch to a different conan version, but we are mostly using our own helpers (predating the upstream ones), so I don’t think this will cause problems for us.
Verified the branch against some arm cross builds. Seems to work fine.
Just for your information: We used to rely on the environment settings exposed by openembedded environment setup script (as generated by the Yocto SDK builds) to forward the required compiler settings to Conan and CMake. However, we ran into more and more problems with that approach because a lot of third party software (like e.g. Amazon AWS) use
execute_process
to spawn subordinate CMake builds for transitive dependencies which sometimes doesn’t forward the environment settings properly. So in the end we decided to always generate CMake toolchain files for cross compilation cases (by manually generating them from the setting in the openembedded setup script) because that is the ‘natural’ way of injecting toolchains into CMake. So from our point of view I’d recommend to not useCC
,CXX
etc. settings in[env]
section at all.@memsharded: Suggested solution #8097 is working for my use case.