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

    <tr>
        <th>Summary</th>
        <td>
            [clang][RISCV] /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          andreas-schwab
      </td>
    </tr>
</table>

<pre>
    $ clang -v --target=riscv64-linux hello.c
clang version 17.0.4
Target: riscv64-unknown-linux
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang-17.0.4" -cc1 -triple riscv64-unknown-linux -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic-rv64 -target-feature +m -target-feature +a -target-feature +f -target-feature +d -target-feature +c -target-feature +zicsr -target-feature -e -target-feature -h -target-feature -svinval -target-feature -svnapot -target-feature -svpbmt -target-feature -v -target-feature -xcvbitmanip -target-feature -xcvmac -target-feature -xsfcie -target-feature -xsfvcp -target-feature -xtheadba -target-feature -xtheadbb -target-feature -xtheadbs -target-feature -xtheadcmo -target-feature -xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac -target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature -xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops -target-feature -zawrs -target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx -target-feature -zbs -target-feature -zca -target-feature -zcb -target-feature -zcd -target-feature -zce -target-feature -zcf -target-feature -zcmp -target-feature -zcmt -target-feature -zdinx -target-feature -zfh -target-feature -zfhmin -target-feature -zfinx -target-feature -zhinx -target-feature -zhinxmin -target-feature -zicbom -target-feature -zicbop -target-feature -zicboz -target-feature -zicntr -target-feature -zifencei -target-feature -zihintpause -target-feature -zihpm -target-feature -zk -target-feature -zkn -target-feature -zknd -target-feature -zkne -target-feature -zknh -target-feature -zkr -target-feature -zks -target-feature -zksed -target-feature -zksh -target-feature -zkt -target-feature -zmmul -target-feature -zve32f -target-feature -zve32x -target-feature -zve64d -target-feature -zve64f -target-feature -zve64x -target-feature -zvfh -target-feature -zvl1024b -target-feature -zvl128b -target-feature -zvl16384b -target-feature -zvl2048b -target-feature -zvl256b -target-feature -zvl32768b -target-feature -zvl32b -target-feature -zvl4096b -target-feature -zvl512b -target-feature -zvl64b -target-feature -zvl65536b -target-feature -zvl8192b -target-feature -experimental-smaia -target-feature -experimental-ssaia -target-feature -experimental-zacas -target-feature -experimental-zfa -target-feature -experimental-zfbfmin -target-feature -experimental-zicond -target-feature -experimental-zihintntl -target-feature -experimental-ztso -target-feature -experimental-zvbb -target-feature -experimental-zvbc -target-feature -experimental-zvfbfmin -target-feature -experimental-zvfbfwma -target-feature -experimental-zvkg -target-feature -experimental-zvkn -target-feature -experimental-zvknc -target-feature -experimental-zvkned -target-feature -experimental-zvkng -target-feature -experimental-zvknha -target-feature -experimental-zvknhb -target-feature -experimental-zvks -target-feature -experimental-zvksc -target-feature -experimental-zvksed -target-feature -experimental-zvksg -target-feature -experimental-zvksh -target-feature -experimental-zvkt -target-feature +relax -target-feature -save-restore -target-abi lp64d -msmall-data-limit 8 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/tmp -resource-dir /usr/lib64/clang/17 -internal-isystem /usr/lib64/clang/17/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/tmp -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/hello-cc167d.o -x c hello.c
clang -cc1 version 17.0.4 based upon LLVM 17.0.4 default target riscv64-suse-linux
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/clang/17/include
 /usr/local/include
 /usr/include
End of search list.
 "/usr/bin/ld" -pie -z relro --hash-style=both --build-id --eh-frame-hdr -m elf64lriscv -X -dynamic-linker /lib/ld-linux-riscv64-lp64d.so.1 -o a.out /lib/../lib64/Scrt1.o /lib/../lib64/crti.o crtbeginS.o -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib64/lp64d -L/usr/lib64/lp64d -L/lib -L/usr/lib /tmp/hello-cc167d.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtendS.o /lib/../lib64/crtn.o
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: cannot find -lgcc_s: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWMFy4zgO_RrlwoLKomQnPuSQbrd3u6pnD9NbvXtLUSQkcUyRKpJSHH_9lCQ76cRw4sOcEj88QgAIQnoUIejaIt4nyy_JcnMj-tg4fy-s8igCBNk8ifKmdOr5PuEFk0bYmsHAAKLwNcYk33gd5LAqwGjb71mDxrhUJotNsniY6QP6oJ1l2W26SIvZ8t_j6gd2Wt7bnXVPdnZzJDUehWKtU2hGaueCPpq-2xCFMag22o-mhG_74BO-LbWdGSzh_A3Kt1M4cAyDcwZSZgyi151BOg4G2OoIrvyLQevRiD0IYxiovu2U9kwAA6WDKA1C5REZSIPCgwgRSqycRyiF3KFVrzxjhhYG9LrS6CdYCq9gEKZHsKLFwKAV2kKlzQycijrH4KSI2lmYysI6LRl0WoLBAQ3j8w8doNPIoK28aBE6p21En-SbKfqqFbEB9N46BlXVgXQ2eiHH3XSWQWUdeNdbpW0NI5dBK50N0fcyOg_CaBHGMKvePmmrII6JhSTfcHbsC5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