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

Override "--target" for clang build #312

Closed iskiselev closed 1 year ago

iskiselev commented 1 year ago

Environment and version details

notice: loading B2 from /mnt/c/VSExclude/agent-dotnet-3/build/bin/vcpkg/x64-linux/x64-linux/tools/boost-build/src/kernel/bootstrap.jam
notice: Site configuration files will be ignored due to the
notice: --ignore-site-config command-line option.
notice: Loading explicitly specified user configuration file:
    /mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg/user-config.jam
notice: Searching '/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg'.
notice: will use '/bin/clang++-16' for clang-linux, condition <toolset>clang-linux-16

Brief problem description

I try to build boost on ubuntu using non-default sysroot (with alpine inside) and overriding setting --target=x86_64-alpine-linux-musl (it is defined in /mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg). But (due to logic in https://github.com/bfgroup/b2/blob/main/src/tools/clang.jam#L95), it always add --target=x86_64-pc-linux. Is there any way to not use hardcoded x86_64-pc-linux target?

Steps to reproduce the issue

Next command called:

/mnt/c/VSExclude/agent-dotnet-3/build/bin/vcpkg/x64-linux/x64-linux/tools/boost-build/b2 toolset=clang --user-config=/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg/user-config.jam --stagedir=/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg/stage --build-dir=/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg runtime-link=shared link=static address-model=64 architecture=x86 target-os=linux threadapi=pthread variant=debug --layout=system -sICU_PATH="ICU_PATH-NOTFOUND" --with-atomic --with-random --with-date_time --with-filesystem --with-system --with-thread --with-chrono -j 17 -sBOOST_ROOT=/mnt/c/VSExclude/agent-dotnet-3/build/bin/vcpkg/x64-linux/x64-linux/tools/boost-build -sBOOST_BUILD_PATH=/mnt/c/VSExclude/agent-dotnet-3/build/bin/vcpkg/x64-linux/x64-linux/tools/boost-build --debug-configuration --debug-building --debug-generators --ignore-site-config --hash -q debug-symbols=on -d +2 threading=multi stage --verbose

Actual behavior summary

It call:

  "/bin/clang++-16" -c -x c++ --target=x86_64-alpine-linux-musl -g "--sysroot=/home/ikiselev/alpine" -m64 -pthread -O0 -fno-inline -Wall -g --target=x86_64-pc-linux  -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_STATIC_LINK=1 -I"../include" -I"/mnt/c/VSExclude/agent-dotnet-3/build/bin/vcpkg/x64-linux/x64-linux-musl/include"   -o "/mnt/c/VSExclude/agent-dotnet-3/vcpkg/buildtrees/boost-system/x64-linux-musl-dbg/boost/build/343884cf2c124864d23ec3d11d30c6f5/error_code.o" "../src/error_code.cpp"

Expected behavior summary

Only target from user-config.jam passed to clang. No additional hard-coded --target=x86_64-pc-linux added.

iskiselev commented 1 year ago

Dup of #255 and #183