Closed
Description
When we build llvm with this cmd
cmake ../llvm -G Ninja -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" -DLLVM_ENABLE_PROJECTS="mlir;clang;clang-tools-extra;lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo
It builds successfully, while if we try do something like
./bin/clang --rtlib=compiler-rt hello.c
Something wrong happens
/usr/bin/aarch64-linux-gnu-ld: cannot find <PATH>/build-aarch64/lib/clang/19/lib/linux/libclang_rt.builtins-aarch64.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
libclang_rt.builtins-aarch64.a
does exists, while in a different path, with a different name
./lib/clang/19/lib/aarch64-linux-gnu/libclang_rt.builtins.a
Activity
llvmbot commentedon Mar 30, 2024
@llvm/issue-subscribers-clang-driver
Author: YunQiang Su (wzssyqa)
It builds successfully, while if we try do something like
Something wrong happens
libclang_rt.builtins-aarch64.a
does exists, while in a different path, with a different namewzssyqa commentedon Apr 1, 2024
Maybe we should fix our build system to always set the directory to the normalized one?
@MaskRay
MaskRay commentedon Apr 1, 2024
Are you building a x86-64 clang that produces aarch64 code on an x86-64 host? The command line does not look correct to me.
I've used the following using
/tmp/Rel/bin/clang
.LLVM_HOST_TRIPLE
is importantNewer Clang will not suggest
libclang_rt.builtins-${arch}.a
. See https://discourse.llvm.org/t/runtime-directory-fallback/76860wzssyqa commentedon Apr 2, 2024
Yes, the normal 'cross toolchain', just like (almost) all embedded cross toolchain with GCC.
In fact I am trying to run mips test with qemu-user.
"Not correct" means that we don't support the change the default output arch on build time?
It is not "normal" cross toolchain.
This cmd will generate a native ARM64 toolchain instead of a cross toolchain for ARM64.
Yes. That's a bug then.
I noticed some code in
ToolChain::getCompilerRT
/clang/lib/Driver/ToolChain.cpp
I have tried to fix this problem. See: #87319
wzssyqa commentedon Apr 2, 2024
In fact, it will fail even for native toolchain, if the -DLLVM_DEFAULT_TARGET_TRIPLE is given with a non-normalized triple.
We have two way:
1. Also search the subdir what -DLLVM_DEFAULT_TARGET_TRIPLE gives us, just as wzssyqa@b0be3f9
2. Fix our build system, install libclang_rt into a normalized subdir always.
MaskRay commentedon Apr 6, 2024
I think the issue is at
ToolChain::getTargetSubDirPath
. When the directory does not exist, we should still add it togetLibraryPaths()
so thatToolChain::getCompilerRT
will report the new compiler-rt file path.I am testing a fix for
ToolChain::getTargetSubDirPath
7 remaining items
llvmbot commentedon Apr 8, 2024
@llvm/issue-subscribers-clang-driver
Author: YunQiang Su (wzssyqa)
It builds successfully, while if we try do something like
Something wrong happens
libclang_rt.builtins-aarch64.a
does exists, while in a different path, with a different nameMaskRay commentedon Apr 9, 2024
Right. This are two issues.
The clang driver issue about an imprecise error message (suggesting the old compiler-rt path) has been fixed by #87866.
The CMake issue is about how to build
libclang_rt.builtins.a
for aarch64 on an x86-64 machine. I haven't done this for a long time. Something like the following does not build compiler-rt. You can create a new issue (or find an existing one).wzssyqa commentedon Apr 10, 2024
In fact compiler-rt is built, while it is present in a different path.
A proposal is: wzssyqa@b0be3f9
In fact,
will work well.
Look for compiler-rt from subdir given by --target
MaskRay commentedon Apr 11, 2024
What's the different path? Can you name the paths to help readers understand the issue without building and debugging cmake or clang driver themselves?
Ensure ToolChain::LibraryPaths is not empty for non-Darwin
[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin
[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin