Skip to content

Incorrect per-target runtime directory #584

@Ignition

Description

@Ignition

Make sure you completed the following tasks

Environment and version details

  • Operating System+version: Linux Ubuntu 24.04.3 LTS
  • Compiler+version: Clang 20.1.7 (built from source with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, the LLVM
    default since LLVM 16)
  • Shell: Bash
  • B2 Version: B2 5.5.0 (OS=LINUX, jobs=24)

Brief problem description

clang.jam init-flags-cross sets vendor = pc ; sys = linux for Linux, producing --target=x86_64-pc-linux.
Clang's actual default triple is x86_64-unknown-linux-gnu. When clang uses the per-target runtime directory layout, b2 looks for lib/x86_64-pc-linux/libclang_rt.asan.a which doesn't exist, the actual path is lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a.
Any link needing the sanitizer runtime fails, including ac library detection tests.

Steps to reproduce the issue

reproduce.sh

Actual behavior summary

With architecture=x86 address-model=64 (triggers init-flags-cross):
notice: loading B2 from /home/gareth/checkout/b2/src/build-system.jam
notice: Searching '/etc' '/home/gareth' '/home/gareth/checkout/b2' '/home/gareth/checkout/b2/src/util' '/home/gareth/checkout/b2/src/tools' '/home/gareth/checkout/b2/src/options' '/home/gareth/checkout/b2/src/engine' '/home/gareth/checkout/b2/src/contrib' '/home/gareth/checkout/b2/src/build' '/home/gareth/checkout/b2/src' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/gareth' '/home/gareth/checkout/b2' '/home/gareth/checkout/b2/src/util' '/home/gareth/checkout/b2/src/tools' '/home/gareth/checkout/b2/src/options' '/home/gareth/checkout/b2/src/engine' '/home/gareth/checkout/b2/src/contrib' '/home/gareth/checkout/b2/src/build' '/home/gareth/checkout/b2/src'.
notice: Loading explicitly specified user configuration file:
    /tmp/tmp.pL3WqbZhbU/user-config.jam
notice: Searching '/tmp/tmp.pL3WqbZhbU' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/tmp/tmp.pL3WqbZhbU'.
notice: will use '/opt/toolchain-v7/bin/clang' for clang-linux, condition <toolset>clang-linux-20
warning: toolset clang-linux initialization: can not find tool windres
warning: initialized from /tmp/tmp.pL3WqbZhbU/user-config.jam:5
notice: using rc compiler :: <toolset>clang-linux-20 :: as
...found 10 targets...
...updating 8 targets...
common.mkdir bin

        mkdir -p "bin"
    
common.mkdir bin/clang-linux-20

        mkdir -p "bin/clang-linux-20"
    
common.mkdir bin/clang-linux-20/debug

        mkdir -p "bin/clang-linux-20/debug"
    
common.mkdir bin/clang-linux-20/debug/address-model-64

        mkdir -p "bin/clang-linux-20/debug/address-model-64"
    
common.mkdir bin/clang-linux-20/debug/address-model-64/architecture-x86

        mkdir -p "bin/clang-linux-20/debug/address-model-64/architecture-x86"
    
common.mkdir bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static

        mkdir -p "bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static"
    
clang-linux.compile.c++ bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test.o

    "/opt/toolchain-v7/bin/clang"   -fsanitize=address -O0 -fno-inline -Wall -g -m64 --target=x86_64-pc-linux       -c -o "bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test.o" "test.cpp"

clang-linux.link bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test

    "/opt/toolchain-v7/bin/clang"    -o "bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test" -Wl,--start-group "bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test.o"  -Wl,-Bstatic  -Wl,-Bdynamic  -Wl,--end-group -g -m64 -fsanitize=address --target=x86_64-pc-linux 

/opt/toolchain-v7/bin/ld: cannot find /opt/toolchain-v7/lib/clang/20/lib/x86_64-pc-linux/libclang_rt.asan_static.a: No such file or directory
/opt/toolchain-v7/bin/ld: cannot find /opt/toolchain-v7/lib/clang/20/lib/x86_64-pc-linux/libclang_rt.asan.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
...failed clang-linux.link bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test...

...updated 7 targets...

...failed updating 1 target...
   clang-linux.link bin/clang-linux-20/debug/address-model-64/architecture-x86/link-static/test

My project is using workaround at the moment of not using ASAN when building boost.

Expected behavior summary

The correct lib path should be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions