bfgroup / b2

B2 makes it easy to build C++ projects, everywhere.
https://www.bfgroup.xyz/b2/
Boost Software License 1.0
76 stars 228 forks source link

Chanfe 397fdf5 weird behavior for cross-compile processes #183

Open badbat75 opened 2 years ago

badbat75 commented 2 years ago

Environment and version details

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

[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
k15tfu commented 2 years ago

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.

dotnwat commented 1 year ago

Same issue here.