I make clang and runtimes builds using my own cmake cache file that I created a while ago looking at the ones provided for Fuchsia in clang/cmake/caches. I build with the following settings in my cache file:
set(LLVM_BUILTIN_TARGETS "x86_64-unknown-linux-gnu;i386-unknown-linux-gnu" CACHE STRING "")
set(LLVM_RUNTIME_TARGETS "x86_64-unknown-linux-gnu;i386-unknown-linux-gnu" CACHE STRING "")
macro(SetBoolForeachTarget Var Value)
set(${Var} ${Value} CACHE BOOL "")
foreach(T ${LLVM_RUNTIME_TARGETS})
set(RUNTIMES_${T}_${Var} ${Value} CACHE BOOL "")
endforeach()
endmacro()
SetBoolForeachTarget(COMPILER_RT_BUILD_BUILTINS ON)
SetBoolForeachTarget(COMPILER_RT_USE_BUILTINS_LIBRARY ON)
It has worked fine for me for multiple releases of LLVM and version 17.0.6 builds without any issues. But I am running into a problem building from trunk. The build fails when linking libc++.so (error is shown below).
ld.lld: error: cannot open /global/LLVM/build/llvm-build-main/x86_64/build-stage2/lib/clang/19/lib/linux/libclang_rt.builtins-i386.a: No such file or directory
It is looking for libclang_rt.builtins-i386.a
in lib/clang/19/lib/linux
. I am not sure why it is looking for it there instead of picking up lib/clang/19/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a
. Please note that this issue is there only with trunk and release/17 works fine (I have not checked 18 rc). What changed in trunk (19.0.0git) w.r.t. release/17 and if it is a problem with my cache file how should I change it to fix this failure?
I have uploaded my full cache file here
Here is the command line that fails during build:
FAILED: /global/LLVM/build/llvm-build-main/x86_64/build-stage2/lib/i386-unknown-linux-gnu/libc++.so.1.0
: && /global/LLVM/build/llvm-build-main/x86_64/build-stage2/./bin/clang++ --target=i386-unknown-linux-gnu -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -shared -Wl,-soname,libc++.so.1 -o /global/LLVM/build/llvm-build-main/x86_64/build-stage2/lib/i386-unknown-linux-gnu/libc++.so.1.0 libunwind/src/CMakeFiles/unwind_shared_objects.dir/libunwind.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-EHABI.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-seh.cpp.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindLevel1.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindLevel1-gcc-ext.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-sjlj.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/Unwind-wasm.c.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindRegistersRestore.S.o libunwind/src/CMakeFiles/unwind_shared_objects.dir/UnwindRegistersSave.S.o libcxx/src/CMakeFiles/cxx_shared.dir/algorithm.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/any.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/bind.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/call_once.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/charconv.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/chrono.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/error_category.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/exception.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/filesystem/filesystem_clock.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/filesystem/filesystem_error.cpp.o libcxx/src/CMakeFiles/cxx_shared.dir/filesystem/path.cpp.o ...
ld.lld: error: cannot open /global/LLVM/build/llvm-build-main/x86_64/build-stage2/lib/clang/19/lib/linux/libclang_rt.builtins-i386.a: No such file or directory
ld.lld: error: cannot open /global/LLVM/build/llvm-build-main/x86_64/build-stage2/lib/clang/19/lib/linux/libclang_rt.builtins-i386.a: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Wonder if the issue discussed in this post is related.
UPDATE Another data point is that the build goes through if I do not build 32-bit runtimes. So this could be a problem with the clang driver.