Description of problem: When compiling for RISC-V, clang unconditionally invokes /usr/bin/ld, i.e. even when -fuse-ld=lld or -fuse-ld=/usr/bin/ld.lld is specified. Version-Release number of selected component (if applicable): clang-9.0.0-1.fc31.x86_64 How reproducible: always Steps to Reproduce: 1. echo 'int _start() {while(1);}' > foo.c 2. clang --target=riscv64 -fuse-ld=lld -nostdlib -v foo.c -o foo 3. echo $? Actual results: [..] clang-9: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument] [..] /usr/bin/ld: /tmp/foo-8bcfba.o: Relocations in generic ELF (EM: 243) /usr/bin/ld: /tmp/foo-8bcfba.o: error adding symbols: file in wrong format clang-9: error: ld command failed with exit code 1 (use -v to see invocation) 1 Expected results: [..] [.. no such warning ..] [..] "/usr/bin/ld.lld" [..] 0 Additional info: It works as expected when targeting x86-64: $ clang -fuse-ld=lld -nostdlib -v foo.c -o foo [..] "/usr/bin/ld.lld" [..] $ echo $? 0 Workaround: Link directly, e.g.: $ clang --target=riscv64 -c foo.c -o foo.o $ ld.lld foo.o -o foo $ echo $? 0 file foo foo.o foo: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, not stripped foo.o: ELF 64-bit LSB relocatable, UCB RISC-V, version 1 (SYSV), not stripped
Error confirmed upstream, patch proposed in https://reviews.llvm.org/D74704
Fixed upstream through https://reviews.llvm.org/D74704 / dd230142d8a00f5f30c3930a2407000e845dcfbf.
This got reverted, then applied again and now works fine. This is not exactly a bugfix, so I think we'll wait until llvm 11 and *not* backport that patch. It will leave time for the feature to stabilize.