You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a known issue. LTO is not yet supported on RISC-V fully automatically.
The short-term fix is to pass -plugin-opt=-target-abi=lp64d to your linker, so it can tell LLVM which ABI to use. We hope to do the equivalent automatically soon.
We're getting quite a few reports from Linux kernel CI services that are trying to link RISC-V Linux kernels with ld.lld about this unsupported relocation type.
R_RISCV_ALIGN error - LLD does not support RISC-V linker relaxations. There are patches in progress, but it's a major feature to design. Compile with -mno-relax if you want to link with LLD.
Invalid ABI when linking with LTO - this is not an LLD issue, this is a LLVM issue in the target configuration code. I handed this work off to someone else, but it requires invasive changes to how we configure the backend when we get a new module (As it has been requested to pass the ABI using module metadata). The workaround addresses this feature.
Extended Description
Clang 10.0-rc1 on riscv64-linux (RV64IMAFDC) breaks if LTO is enabled -- apparently the correct ABI isn't passed to the linker:
$ clang -march=rv64imafdc test.c
[works perfectly, binary works]
$ clang -march=rv64imafdc -flto test.c
/usr/bin/ld: /tmp/lto-llvm-f65f95.o: can't link soft-float modules with double-float modules
/usr/bin/ld: failed to merge target specific data of file /tmp/lto-llvm-f65f95.o
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
$ clang -march=rv64imafdc -flto -fuse-ld=lld test.c
ld.lld: error: lto.tmp: cannot link object files with different floating-point ABI
ld.lld: error: static-reloc.c:(.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax
ld.lld: /builddir/build/BUILD/llvm-project-release-10.x/lld/ELF/Relocations.cpp:987: uint64_t lld::elf::{anonymous}::OffsetGetter::get(uint64_t): Assertion `pieces[i].inputOff <= off && "Relocation not in any piece"' failed.
Stack dump:
0. Program arguments: /usr/bin/ld.lld --build-id --eh-frame-hdr -m elf64lriscv -dynamic-linker /lib/ld-linux-riscv64-lp64d.so.1 -o a.out /usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/../../../../lib64/crt1.o /usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/crti.o /usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/crtbegin.o -L/usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1 -L/usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib64/lp64d -L/usr/lib64/lp64d -L/usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/../../../../riscv64-openmandriva-linux-gnu/lib -L/usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib -plugin /usr/bin/../lib64/LLVMgold.so /tmp/test-6791f6.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/crtend.o /usr/bin/../lib64/gcc/riscv64-openmandriva-linux-gnu/9.2.1/crtn.o
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: error: linker command failed due to signal (use -v to see invocation)
The text was updated successfully, but these errors were encountered: