Description
clang::ToolChain::getCompilerRT(...)
searches for the location of the clang_rt.builtins
library. It considers the paths with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
(clang_rt.builtins.lib
) as well as LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF
(clang_rt.builtins-x86_64.lib
). When it does not find it, it falls back to clang_rt.builtins.lib
(since #87866).
This might be fine for platforms such as Linux where LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
is the default, but breaks for platforms where it is off by default. In particular, under Windows the file is usually located under ${prefix}/lib/clang/${version}/lib/windows/clang_rt.builtins-x86_64.lib
. If it is missing (e.g. in non-bootstrap builds), MSVC's toolchain also provides its own version e.g. C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\lib\clang\18\lib\windows\clang_rt.builtins-x86_64.lib
. With the change #87866 https://github.com/llvm/llvm-project/pull/87866/files#diff-58fde3c498133c1f93ff2df8cb10083eb6955637187074e16a87bd93cd1364f0R799-R805 the driver tells the linker to use clang_rt.builtins.lib
which does not exist in any common configuration under Windows.
Also see #87866 (comment)