<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/202159>202159</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V][lld] ld.lld stack align mismatch not rejected (before LLVM 16)
</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 14.0.6/15.0.7 link the mismatched set successfully and still emit an output file. ld.lld 16.0.6 and 21.1.3 reject the same link with stack_align=32 vs stack_align=16.
### Expected behavior
Link three ordinary RV64 objects with stack_align=16 together with one ordinary RV64 object that declares stack_align=32. This is a meaningful attribute-merge check: incompatible stack alignment requirements must be rejected at link time.
### 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:
#### `a.s`
```asm
.attribute stack_align, 16
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zmmul1p0"
.attribute unaligned_access, 0
```
#### `b.s`
```asm
.attribute stack_align, 16
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zmmul1p0"
.attribute priv_spec, 2
.attribute priv_spec_minor, 2
```
#### `c.s`
```asm
.attribute stack_align, 16
.attribute arch, "rv64i2p1_f2p2_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
.attribute unaligned_access, 1
.attribute priv_spec, 2
.attribute priv_spec_minor, 2
```
#### `diff_stack_align.s`
```asm
.attribute stack_align, 32
```
### 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_stack_align_mismatch_not_rejected_before_16/run1..run3 show stable assembly success for a.o, b.o, c.o, and diff_stack_align.o, stable 14/15 exit 0 with linked outputs stack.14 and stack.15, and stable 16/21 link-time errors reporting the stack_align mismatch.
### Notes
upstream///llvm-project/lld/test/ELF/riscv-attributes.s (stack_align merge reduction)
Root key: `lld.riscv.stack_align_mismatch_not_rejected_before_16`
Case id: `20260527-lld-stack-align-mismatch-not-rejected`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMV19v27oV_zTyy4EFibKU-MEPaVLjBujdQ9p1ezMo8sjiQpEaD-nU_fQDKctOWufudsCGAYYtk-f8zv8_4kRqbxA3Wf0hqx8WPPjeus3fFbetMvvfbChZuV60Vh43j-C4AWW8Bd8rgpdeaQSHMghl9sDh6fHz_fIraGWe0YFH8oIT5vClj2SjszIIdKAIaOBaZ-weuJHwCD0_ILSIBggxYvkegfgQ2ShoD8IaUuTReH0ELpwlAt87jAQuGMqz4iEr7k7frJo-8DkMA3fH6VjLXGsJ5Sov8iZj27LOi_wmaZvkDYoG7kWPEgg9UBACibqgo0gjgbzSGnBQHrgBG_wYPHRKYw4zdBOhEzEr8zKvwOE_UPiLOUnYi_I9kOfiece12puseqgYHOiHs7J5x6qP30YUHiW02PODsm4i-DQZEp1inVSGuyM8fW1WYNuoBF2TWzbg7R59j266tuY6N_iee5AoNHf4o6YVizFWFCPLYUBulNl3QQP33qk2eFwO6PYIokfxnFV3oIyww8i9ajVOYJDABjQeHP4zKIfxmWAI5KHFkydRAvenkKkB33OQOShnE9h0tZxz0tngMSqg9WFYDgIYg1EHmiN4QEfKmpitmh9n5oE70Ucud2hW6nLaqgQ1Nqv5rFOOPHRc6ZjF5Pl-kqbM81kTK7iOV63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