<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202154>202154</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld relax GP option unsupported (before LLVM 17)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
XiaobingHou1219
</td>
</tr>
</table>
<pre>
I ran into this while reducing a RISC-V linker testcase. The reproducer is small, and I have been seeing the same result consistently across three reruns.
### Summary
ld.lld 16.0.6 rejects the legal RISC-V link with `unknown argument /'--relax-gp/'`, while 17.0.6 and 22.1.0 accept the option and link the same input successfully.
### Expected behavior
Link a small-data RV64 executable with explicit `--relax-gp` enabled.
### Environment
- linker route: llvm-mc 22 plus ld.lld version replay
- march: rv64i
- mabi: lp64
- first failing stage: link
- local stability check: True
### Reduced testcase
These are the reduced input files from the minimized reproducer I used locally:
#### `case.s`
```asm
.global _start
_start:
lui a0, %hi(foo)
addi a0, a0, %lo(foo)
lw a0, %lo(foo)(a0)
sw a0, %lo(foo)(a0)
lui a0, %hi(bar)
addi a0, a0, %lo(bar)
lb a0, %lo(bar)(a0)
sb a0, %lo(bar)(a0)
lui a0, %hi(norelax)
addi a0, a0, %lo(norelax)
lw a0, %lo(norelax)(a0)
sw a0, %lo(norelax)(a0)
lui a0, %hi(undefined_weak)
addi a0, a0, %lo(undefined_weak)
lw a0, %lo(undefined_weak)(a0)
sw a0, %lo(undefined_weak)(a0)
lui a0, %hi(baz)
addi a0, a0, %lo(baz)
lw a0, %lo(baz)(a0)
sw a0, %lo(baz)(a0)
a:
addi a0, a0, 1
.section .sdata,"aw"
foo:
.word 0
.space 4091
bar:
.byte 0
norelax:
.word 0
.weak undefined_weak
```
#### `layout.ld`
```ld
SECTIONS {
.text : {*(.text) }
.sdata 0x200000 : { }
}
```
### Reproduction notes
- This packaged root does not have a single canonical `run.ps1` wrapper.
- Use the reduced inputs under `case/` and follow the commands documented in `case/README.md`.
- Stable witness outputs, when present, are preserved under `verify/run1..run3/`.
### What I checked
- Reduced inputs are preserved under case/.
- Stable witness outputs are preserved under verify/run1..run3/.
- The strict recheck says stable normalized run signatures across three runs: True.
- Tracker guidance link: https://llvm.org/docs/HowToSubmitABug.html
- evidence summary: 3 clean reproductions under hunt/verify/lld_relax_gp_option_unsupported_before_17/run1..run3 show stable assembly success for rv64.o, stable 16.0.6 link-time rejection with `unknown argument /'--relax-gp/'`, and stable 17.0.6/22.1.0 successful links whose objdump files are materialized as out.17.objdump.txt and out.22.objdump.txt.
### Notes
upstream////llvm-project//lld//test//ELF//riscv-relax-hi20-lo12.s and LLVM 17.0.1 lld release notes
Root key: `lld.riscv.relax_gp_option_unsupported_before_17`
Case id: `20260527-lld-relax-gp-option-unsupported`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycV91u47oRfhr5ZmBBomPZvvBFNj89AfacFkm67V1AiWOJG4oUOKQdn6cvSEm2s3Y2QYPAkMiP88-ZT5xI1hpxncy_JfPbCfeuMXb9X8lNKXX9h_E5y1eT0oj9-gEs1yC1M-AaSbBrpEKwKHwldQ0cHh-ebqY_QEn9ihYckqs4YQrPTYB11ghfoQVJQC1XKmE3wLWAB2j4FqFE1ECIQZZrEIi34Rh55aAymiQ51E7tgVfWEIFrLAaA9ZrSJLtNsuvhl836f3jybcvtvl9WIlVKQF6kWVqAxZ9YOYqaFNZcnVoPO-kaSIrM61dtdhq4rX2L2kHC7hO2mE4tKv42rbv-PSmy4EwfkHwRFQTPGEvzNANeVdi5qMp0ThodN6Oig6NSd94B-apCoo1Xav-BT3dvHVYOBZTY8K00tgd8D9J4H9ip4I7D44_iCvANK-94qbD3Cd86JSvpgnMnXhQZoA4o8ZFWvZXW6BCDfms6ptka7zCZXYNS23baVsAYdMoTDPHeoqXgssVO8f14uOW2asIpuy2u5HG1lFFUV1yNaxtpycGGSxUKgxyve21Svx4sMRV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