Bug 1803698 - Clang option -fuse-ld=lld is ignored with RISC-V targets
Summary: Clang option -fuse-ld=lld is ignored with RISC-V targets
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Fedora
Classification: Fedora
Component: clang
Version: 31
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: serge_sans_paille
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-17 09:36 UTC by Georg Sauthoff
Modified: 2020-02-27 13:23 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-02-27 13:23:28 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Georg Sauthoff 2020-02-17 09:36:33 UTC
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

Comment 1 serge_sans_paille 2020-02-17 13:06:10 UTC
Error confirmed upstream, patch proposed in https://reviews.llvm.org/D74704

Comment 2 serge_sans_paille 2020-02-18 10:26:39 UTC
Fixed upstream through https://reviews.llvm.org/D74704 / dd230142d8a00f5f30c3930a2407000e845dcfbf.

Comment 3 serge_sans_paille 2020-02-27 13:23:28 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.