Cross compile Aarch64 application libraries that have dependencies on boost libraries (using bincrafters boost*/1.69.0) results in the correct ELF file format for the application library but not for for the boost libraries. The boost_system and boost_filesystem static libraries have the ELF format of the host arch, x86-64, and not in the target arch, Aarch64. Using readelf to verify the file format shows the boost libraries are built for the host arch. However, the application library compiles to the correct file format: aarch64. Linker errors arise when the application attempts to link in the boost libraries throws a linker format error.
I noticed that no toolset flag is passed to b2. There are discussions which suggest b2 gets the compiler toolchain from CC and CXX environment variables.
boost_filesystem/1.69.0@bincrafters/stable: Applying build-requirement: boost_generator/1.69.0@bincrafters/stable
boost_filesystem/1.69.0@bincrafters/stable: Applying build-requirement: boost_build/1.69.0@bincrafters/stable
boost_filesystem/1.69.0@bincrafters/stable: Copying sources to build folder
boost_filesystem/1.69.0@bincrafters/stable: Building your package in /home/ubuntu/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/build/e716871d1f049626249e979de402d6d8103a6013
boost_filesystem/1.69.0@bincrafters/stable: Generator boost created jamroot
boost_filesystem/1.69.0@bincrafters/stable: Generator boost created boostcpp.jam
boost_filesystem/1.69.0@bincrafters/stable: Generator boost created project-config.jam
boost_filesystem/1.69.0@bincrafters/stable: Generator boost created short_path.cmd
boost_filesystem/1.69.0@bincrafters/stable: Calling build()
boost_filesystem/1.69.0@bincrafters/stable: /home/ubuntu/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/build/e716871d1f049626249e979de402d6d8103a6013: b2 -j4 -d+1 -a --hash=yes --debug-configuration --layout=system filesystem-build
notice: found boost-build.jam at /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/boost-build.jam
notice: loading Boost.Build from /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/kernel
/home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:50: Unescaped special character in argument ([^.]*)$
/home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:204: Unescaped special character in argument os:
/home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:205: Unescaped special character in argument os:
notice: Searching . for project-config configuration file project-config.jam
notice: Loading project-config configuration file 'project-config.jam' from '.'.
notice: will use 'g++-7' for gcc, condition gcc-7.5.0
notice: using gcc libraries :: gcc-7.5.0 :: /usr/bin /usr/lib /usr/lib32 /usr/lib64
notice: using gcc archiver :: gcc-7.5.0 :: /usr/bin/ar
notice: using gcc ranlib :: gcc-7.5.0 :: /usr/bin/ranlib
warning: toolset gcc initialization: can not find tool windres
warning: initialized from project-config.jam:4
notice: using rc compiler :: gcc-7.5.0 :: /usr/bin/as
warning: toolset mpi initialization: can not find tool mpic++
warning: initialized from project-config.jam:58
MPI auto-detection failed: unknown wrapper compiler mpic++
Please report this error to the Boost mailing list: http://www.boost.org
You will need to manually configure MPI support.
warning: toolset mpi initialization: can not find tool mpirun
warning: initialized from project-config.jam:58
MPI launcher: mpirun -np
Problem
Cross compile Aarch64 application libraries that have dependencies on boost libraries (using bincrafters boost*/1.69.0) results in the correct ELF file format for the application library but not for for the boost libraries. The
boost_system
andboost_filesystem
static libraries have the ELF format of the host arch, x86-64, and not in the target arch, Aarch64. Usingreadelf
to verify the file format shows the boost libraries are built for the host arch. However, the application library compiles to the correct file format: aarch64. Linker errors arise when the application attempts to link in the boost libraries throws a linker format error.I noticed that no toolset flag is passed to b2. There are discussions which suggest b2 gets the compiler toolchain from CC and CXX environment variables.
Environment Details
Steps to reproduce
conanfile.py
def build(self): cmake = CMake(self) cmake.verbose = True self.build_folder = self.getBuildFolder() cmake.configure() cmake.build()
Profile
toolchain=/usr/aarch64-linux-gnu target_host=aarch64-linux-gnu cc_compiler=gcc cxx_compiler=g++
[env] CONAN_CMAKE_FIND_ROOT_PATH=$toolchain CHOST=$target_host AR=$target_host-ar AS=$target_host-as RANLIB=$target_host-ranlib CC=$target_host-$cc_compiler CXX=$target_host-$cxx_compiler STRIP=$target_host-strip RC=$target_host-windres
[settings] os_build=Linux arch_build=x86_64 os=Linux arch=armv8 compiler=gcc compiler.cppstd=11 compiler.version=7.5 compiler.libcxx=libstdc++11 build_type=Release
Conan Command
$ conan install . -pr=aarch64 -g ycm --build=missing
Logs
boost_filesystem/1.69.0@bincrafters/stable: Applying build-requirement: boost_generator/1.69.0@bincrafters/stable boost_filesystem/1.69.0@bincrafters/stable: Applying build-requirement: boost_build/1.69.0@bincrafters/stable boost_filesystem/1.69.0@bincrafters/stable: Copying sources to build folder boost_filesystem/1.69.0@bincrafters/stable: Building your package in /home/ubuntu/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/build/e716871d1f049626249e979de402d6d8103a6013 boost_filesystem/1.69.0@bincrafters/stable: Generator boost created jamroot boost_filesystem/1.69.0@bincrafters/stable: Generator boost created boostcpp.jam boost_filesystem/1.69.0@bincrafters/stable: Generator boost created project-config.jam boost_filesystem/1.69.0@bincrafters/stable: Generator boost created short_path.cmd boost_filesystem/1.69.0@bincrafters/stable: Calling build() boost_filesystem/1.69.0@bincrafters/stable: /home/ubuntu/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/build/e716871d1f049626249e979de402d6d8103a6013: b2 -j4 -d+1 -a --hash=yes --debug-configuration --layout=system filesystem-build
notice: found boost-build.jam at /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/boost-build.jam notice: loading Boost.Build from /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/kernel /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:50: Unescaped special character in argument ([^.]*)$ /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:204: Unescaped special character in argument os: /home/ubuntu/.conan/data/boost_build/1.69.0/bincrafters/stable/package/44fcf6b9a7fb86b2586303e3db40189d3b511830/share/boost-build/src/util/os.jam:205: Unescaped special character in argument os:
notice: Searchinggcc-7.5.0
notice: using gcc libraries :: gcc-7.5.0 :: /usr/bin /usr/lib /usr/lib32 /usr/lib64
notice: using gcc archiver :: gcc-7.5.0 :: /usr/bin/ar
notice: using gcc ranlib :: gcc-7.5.0 :: /usr/bin/ranlib
warning: toolset gcc initialization: can not find tool windres
warning: initialized from project-config.jam:4
notice: using rc compiler :: gcc-7.5.0 :: /usr/bin/as
.
for project-config configuration file project-config.jam notice: Loading project-config configuration file 'project-config.jam' from '.'. notice: will use 'g++-7' for gcc, condition===============MPI Auto-configuration===============
warning: toolset mpi initialization: can not find tool mpic++ warning: initialized from project-config.jam:58 MPI auto-detection failed: unknown wrapper compiler mpic++ Please report this error to the Boost mailing list: http://www.boost.org
You will need to manually configure MPI support. warning: toolset mpi initialization: can not find tool mpirun warning: initialized from project-config.jam:58 MPI launcher: mpirun -np
====================================================
...patience... ...found 690 targets... ...updating 20 targets... common.copy filesystem/lib/jamroot.jam gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/codecvt_error_category.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/path_traits.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/path.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/portability.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/windows_file_codecvt.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/utf8_codecvt_facet.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/unique_path.o gcc.compile.c++ bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/operations.o gcc.archive bin/filesystem/build/40e50b6fcfbdeee7a5ce788729697f7f/libboost_filesystem.a common.copy filesystem/lib/libboost_filesystem.a ...updated 20 targets...
Files
~/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/build/e716871d1f049626249e979de402d6d8103a6013/conaninfo.txt
[settings] arch=armv8 build_type=Release compiler=gcc compiler.cppstd=11 compiler.libcxx=libstdc++11 compiler.version=7.5 os=Linux
[requires] boost_assert/1.69.0 boost_config/1.69.0 boost_container_hash/1.69.0 boost_core/1.69.0 boost_detail/1.69.0 boost_io/1.69.0 boost_iterator/1.69.0 boost_smart_ptr/1.69.0 boost_static_assert/1.69.0 boost_system/1.69.0 boost_type_traits/1.69.0 boost_winapi/1.69.0
[options] shared=False
[full_settings] arch=armv8 build_type=Release compiler=gcc compiler.cppstd=11 compiler.libcxx=libstdc++11 compiler.version=7.5 os=Linux
[full_requires] boost_assert/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_config/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_container_hash/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_core/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_detail/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_io/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_iterator/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_smart_ptr/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_static_assert/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_system/1.69.0@bincrafters/stable:21385ca39f18d1f23fcd16997d7f9cdae2bb9187 boost_type_traits/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 boost_winapi/1.69.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
[full_options] shared=False boost_system:shared=False
[recipe_hash] d495f4151d73ec9e9104648270d2733e
[env] AR=aarch64-linux-gnu-ar AS=aarch64-linux-gnu-as CC=aarch64-linux-gnu-gcc CHOST=aarch64-linux-gnu CONAN_CMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu CXX=aarch64-linux-gnu-g++ RANLIB=aarch64-linux-gnu-ranlib RC=aarch64-linux-gnu-windres STRIP=aarch64-linux-gnu-strip
Verification
After the build completes, verify the boost library and the application library are in the correct ELF format.
boost_filesystem library
$ cd ~/.conan/data/boost_filesystem/1.69.0/bincrafters/stable/package/e716871d1f049626249e979de402d6d8103a6013/filesystem/lib $ readelf -h libboost_filesystem.a |grep 'Class|File|Machine'
File: libboost_filesystem.a(codecvt_error_category.o) Class: ELF64 Machine: Advanced Micro Devices X86-64 ... File: libboost_filesystem.a(windows_file_codecvt.o) Class: ELF64 Machine: Advanced Micro Devices X86-64
Application library that has the dependency on boost_filesystem:
$ cd ~/.conan/data/Framework/0.0.1/local/stable/package/fe506ce82bcde262b659ab8e4edc7854d777cb2c/lib $ readelf -h libFramework.a |grep 'Class|File|Machine'
File: libFramework.a(TestLogger.cpp.o) Class: ELF64 Machine: AArch64
*Note: boost is in the x86-64 format whereas the application library is in the Aarch64 format