<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59026>59026</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ld.lld: error: unable to find library -lclang_rt.builtins-riscv64 for using clang to compile hello word for riscv
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dshm
      </td>
    </tr>
</table>

<pre>
    I want use llvm to generate code to riscv target, and  I following the following step:
cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;clang-tools
-extra;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld;polly;debuginfo-tests" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=On -DDEFAULT_SYSROOT="/data/dushaomin/task20221109/test2/install/riscv64-unknown-elf" -DGCC_INSTALL_PREFIX="/data/dushaomin/task20221109/test2/install" -DLLVM_TARGETS_TO_BUILD="RISCV" ../llvm

make -j

the above steps build successfully. 

but when I use the generated clang to compile hello world to riscv, it get ld.lld: error: unable to find library -lclang_rt.builtins-riscv64. I have seen https://github.com/llvm/llvm-project/issues/56196 . The issus said it was the problem of compiler-rt, but my compiler-rt is built successful. 

the hello.c I use is:
#include<stdio.h>
int main()
{

        printf("hello\n");
        return 0;
}

the command I use is  clang --target=riscv64 -march=rv64gc ./hello.c -o helloclang

As I have set -DDEFAULT_SYSROOT and -DGCC_INSTALL_PREFIX when cmake, I think it is not need to set --sysroot and --gcc-toolchain when using clang. refering to https://stackoverflow.com/questions/68580399/using-clang-to-compile-for-risc-v/68583104#68583104  
The llvm-project I use is tag llvmorg-12.0.0-rc5. I also tried latter version but they can't make successful. Do I miss some important steps? And how can I solve the problem "ld.lld: error: unable to find library -lclang_rt.builtins-riscv64"?  Thank you and wait for help!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llv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