Chanfe 397fdf5 weird behavior for cross-compile processes
Environment and version details
- Operating System+version: Fedora 36
- Compiler+version: Clang 14.0.6
- Shell: Bash
- B2 Version:
b2 -v
B2 Version 4.9. OS=LINUX.
Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
Copyright 2001 David Turner.
Copyright 2001-2004 David Abrahams.
Copyright 2002-2019 Rene Rivera.
Copyright 2003-2015 Vladimir Prus.
DEFAULTS: jobs = 8
b2 --version
B2 4.9-git
b2 embedded in boost libraries 1.80
- B2 Configuration:
b2 --debug-configuration
Performing configuration checks
- default address-model : 32-bit [1]
- default architecture : arm [1]
- has std::atomic_ref : no [2]
- has statx : yes [2]
- has init_priority attribute : yes [2]
- has stat::st_blksize : yes [2]
- has stat::st_mtim : yes [2]
- has stat::st_mtimensec : no [2]
- has stat::st_mtimespec : no [2]
- has stat::st_birthtim : no [2]
- has stat::st_birthtimensec : no [2]
- has stat::st_birthtimespec : no [2]
- has fdopendir(O_NOFOLLOW) : yes [2]
- has POSIX *at APIs : yes [2]
- cxx11_auto_declarations : yes [2]
- cxx11_constexpr : yes [2]
- cxx11_defaulted_functions : yes [2]
- cxx11_final : yes [2]
- cxx11_hdr_mutex : yes [2]
- cxx11_hdr_tuple : yes [2]
- cxx11_lambdas : yes [2]
- cxx11_noexcept : yes [2]
- cxx11_nullptr : yes [2]
- cxx11_rvalue_references : yes [2]
- cxx11_template_aliases : yes [2]
- cxx11_thread_local : yes [2]
- cxx11_variadic_templates : yes [2]
- cxx11_auto_declarations : yes [3]
- cxx11_constexpr : yes [3]
- cxx11_defaulted_functions : yes [3]
- cxx11_final : yes [3]
- cxx11_hdr_mutex : yes [3]
- cxx11_hdr_tuple : yes [3]
- cxx11_lambdas : yes [3]
- cxx11_noexcept : yes [3]
- cxx11_nullptr : yes [3]
- cxx11_rvalue_references : yes [3]
- cxx11_template_aliases : yes [3]
- cxx11_thread_local : yes [3]
- cxx11_variadic_templates : yes [3]
- has_icu builds : yes [2]
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam.
note: to suppress this message, pass "--without-graph_parallel" to bjam.
- zlib : yes
- bzip2 : yes
- lzma : yes
- zstd : yes
- has_lzma_cputhreads builds : yes [2]
- cxx11_decltype : yes [2]
- cxx11_basic_alignas : yes [2]
- iconv (libc) : yes [2]
- icu : yes [2]
- lockfree boost::atomic_flag : yes [2]
- native atomic int32 supported : yes [2]
- native syslog supported : yes [2]
- pthread supports robust mutexes : yes [2]
- gcc visibility : yes [2]
- sfinae_expr : yes [2]
- cxx11_unified_initialization_syntax : yes [2]
- cxx11_hdr_initializer_list : yes [2]
- cxx11_hdr_chrono : yes [2]
- cxx11_numeric_limits : yes [2]
- cxx11_hdr_array : yes [2]
- cxx11_hdr_atomic : yes [2]
- cxx11_hdr_type_traits : yes [2]
- cxx11_allocator : yes [2]
- cxx11_explicit_conversion_operators : yes [2]
- long double support : yes [2]
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
- cxx11_static_assert : yes [2]
- std::fstream is moveable and swappable : yes [2]
- Has Large File Support : yes [2]
- Has attribute init_priority : yes [2]
- libbacktrace builds : no [2]
- libbacktrace builds : no [3]
- addr2line builds : no [2]
- addr2line builds : no [3]
- WinDbg builds : no [2]
- WinDbg builds : no [3]
- WinDbgCached builds : no [2]
- WinDbgCached builds : no [3]
- BOOST_COMP_GNUC >= 4.3.0 : no [2]
- BOOST_COMP_GNUC >= 4.3.0 : no [4]
- cxx11_hdr_thread : yes [2]
- cxx11_hdr_regex : yes [2]
[1] clang-14
[2] clang-linux-14/release/abi-aapcs/lto-on-thin/python-3.9/threadapi-pthread/threading-multi/visibility-hidden
[3] clang-linux-14/release/abi-aapcs/build-no/lto-on-thin/python-3.9/threadapi-pthread/threading-multi/visibility-hidden
[4] clang-linux-14/release/abi-aapcs/link-static/lto-on-thin/python-3.9/threadapi-pthread/threading-multi/visibility-hidden
Brief problem description
Cross compiling for arm-linux-gnueabihf generates weird target option for clang
Steps to reproduce the issue
./b2 -j7 -q architecture=arm address-model=32 binary-format=elf abi=aapcs target-os=linux variant=release optimization=speed lto=on lto-mode=thin threading=multi -d+1 link=shared runtime-link=shared toolset=clang 'cflags=--sysroot=/mnt/distos -march=armv6kz -mtune=arm1176jzf-s -mfpu=vfpv2 -mfloat-abi=hard -marm ' 'cxxflags=-I/mnt/binaries/usr/include -I/mnt/distos/usr/include -I/mnt/distos/usr/include/arm-linux-gnueabihf -I/mnt/distos/usr/include/c++/10 -I/mnt/distos/usr/include/arm-linux-gnueabihf/c++/10 -I/mnt/distos/usr/include/python3.9 -fPIC ' 'linkflags=--target=arm-linux-gnueabihf --sysroot=/mnt/distos -fuse-ld=lld -Wl,--threads=7 -Wl,-rpath-link,/mnt/binaries/lib/arm-linux-gnueabihf -L/mnt/binaries/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/binaries/usr/lib/arm-linux-gnueabihf -L/mnt/binaries/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/distos/lib/arm-linux-gnueabihf -L/mnt/distos/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/distos/usr/lib/arm-linux-gnueabihf -L/mnt/distos/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/distos/usr/lib/gcc/arm-linux-gnueabihf/10 -L/mnt/distos/usr/lib/gcc/arm-linux-gnueabihf/10 ' install
where in /mnt/distos I mounted the target system image and /mnt/binaries some dependencies for boostlib
Actual behavior summary
the generated clang command is:
clang --target=arm-pc-linux ......
In order to force the compilation I had to force the target parameter with "./b2 ... cflags=--target=arm-linux-gnueabihf... ..." in this case the output is
clang --target=arm-pc-linux --target=arm-linux-gnueabihf ......
that is a mess but at least it overrides the weird target clang option.
Expected behavior summary
The correct arch string should be:
clang --target=arm-linux-gnueabihf ......
I haven't tested other arch targets, but I expect the same issue for aarch64-linux-gnu... In previous versions of b2 target option were not generated so I used to force anyway the target option for clang
I have the same issue after upgrading to Boost 1.80.0 on Linux ARM32, the build error looks like:
clang-linux.compile.c++ .bin/clang80.static.arm/boost/bin.v2/libs/chrono/build/clang-linux-8/release/link-static/threading-multi/visibility-hidden/thread_clock.o
clang-8: warning: unknown platform, assuming -mfloat-abi=soft
clang-8: warning: unknown platform, assuming -mfloat-abi=soft
In file included from libs/chrono/src/thread_clock.cpp:18:
In file included from ./boost/chrono/detail/inlined/thread_clock.hpp:14:
In file included from ./boost/chrono/config.hpp:15:
In file included from ./boost/config.hpp:44:
In file included from ./boost/config/detail/select_stdlib_config.hpp:24:
In file included from /opt/clang/bin/../include/c++/v1/version:117:
In file included from /opt/clang/bin/../include/c++/v1/__config:206:
/usr/include/features.h:364:12: fatal error: 'sys/cdefs.h' file not found
# include <sys/cdefs.h>
^~~~~~~~~~~~~
1 error generated.
"clang++" -c -x c++ -fvisibility-inlines-hidden -pthread -O3 -Wall -Wextra -pedantic -fvisibility=hidden -Wno-inline --target=arm-pc-linux -Wno-long-long -Wno-variadic-macros -std=c++17 -stdlib=libc++ -fpic -DBOOST_ALL_NO_LIB=1 -DBOOST_All_STATIC_LINK=1 -DNDEBUG -I"." -o ".bin/clang80.static.arm/boost/bin.v2/libs/chrono/build/clang-linux-8/release/link-static/threading-multi/visibility-hidden/thread_clock.o" "libs/chrono/src/thread_clock.cpp"
...failed clang-linux.compile.c++ .bin/clang80.static.arm/boost/bin.v2/libs/chrono/build/clang-linux-8/release/link-static/threading-multi/visibility-hidden/thread_clock.o...
For now, I tried to revert https://github.com/bfgroup/b2/commit/397fdf56b7c409ea2d3dfd687a3ebdf319baa95d as a workaround.
Same issue here.