This is an archive of the discontinued LLVM Phabricator instance.

Linker is unable to find -lclang_rt.builtins-riscv64 library
Needs ReviewPublic

Authored by ramakotareddy on Jul 16 2023, 2:58 AM.

Details

Reviewers
chandlerc
Summary

LLVM RISCV target clang binary is unable to find the "-lclang_rt.builtins-riscv64" library from baremetal directory.
But There is a suitable library but with the different name "libclang_rt.builtins.a".

This patch will create baremetal directory and installed "libclang_rt.builtins.a" library in the baremetal directory with " libclang_rt.builtins-riscv64.a" name.

Diff Detail

Event Timeline

ramakotareddy created this revision.Jul 16 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2023, 2:58 AM
ramakotareddy requested review of this revision.Jul 16 2023, 2:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2023, 2:58 AM

hello.c:

int main() {
  return 0;
}

Issue:

With this command build/bin/clang -mcpu=generic-rv64 hello.c getting below error.
Error: ld.lld: error: unable to find library -lclang_rt.builtins-riscv64

After this fix able to run the simple c program using build/bin/clang -mcpu=generic-rv64 hello.c command.

-> I have used below configure options

LD=lld-11 CC='clang-11' CXX='clang++-11' /usr/bin/cmake -S  llvm -B build -G "Ninja" -DLLVM_TARGETS_TO_BUILD="RISCV"  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/llvm_install/  -DLLVM_ENABLE_PROJECTS="clang;lld"  -DLLVM_ENABLE_BINDINGS=false -DDEFAULT_SYSROOT="/tmp/64riscv_linux_gnu_build/install_dir/riscv64-unknown-elf/" -DLLVM_ENABLE_RUNTIMES="compiler-rt"  -DLLVM_BUILD_TESTS=false -DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf" -DCOMPILER_RT_BAREMETAL_BUILD=ON
ayonam added a subscriber: ayonam.Aug 1 2023, 8:37 AM

@asb,
Does this look like a patch that can be reviewed and merged in for fixing the library path issue for baremetal target of RISC-V? If so, can you please review the same?
Thanks and regards
Ayonam

asb added a subscriber: phosek.Aug 9 2023, 3:32 AM

@ramakotareddy @ayonam: I'm not a good reviewer for this CMake change unfortunately. Adding in @phosek who might have more relevant experience or be able to nominate someone who has.

A few notes:

  • Please upload patches with full context (see here for guidance).
  • Hardcoding the LLVM release number in the CMake snippet definitely seems wrong
  • If an appropriate file is being built but the lookup for it is failing, wouldn't it be better to change the clang driver lookup logic?