s0me0ne-unkn0wn opened issue #12811:
Summary
When compiling large functions targeting riscv64gc with compressed instructions (Zca) enabled,
emit_veneer()panics because the veneer is placed too far from the originalC.J.The island emission deadline mechanism is supposed to force island emission before any label reference goes out of range, but, presumably, the deadline calculation doesn't account for the very small range of
C.Jwhen traps and constants are flushed before veneers — these can push the veneer past the 2 KiB limit.
.clifTest CaseSteps to Reproduce
$ clif-util test rvcjump_bug_reduced.clifExpected Results
Success
Actual Results
thread 'worker #0' panicked at cranelift/codegen/src/isa/riscv64/inst/mod.rs:1759:9:
RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range.
note: run withRUST_BACKTRACE=1environment variable to display a backtrace
[2026-03-20T19:04:21Z ERROR cranelift_filetests::concurrent] FAIL: panicked in worker #0: RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range.
FAIL rvcjump_bug_reduced.clif: panicked in worker #0: RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range.
1 tests
Error: 1 failureVersions and Environment
Cranelift version or commit: 0.122.0
Operating system: Linux Manjaro
Architecture: x86_64 cross-compiling to riscv64gc
s0me0ne-unkn0wn added the bug label to Issue #12811.
s0me0ne-unkn0wn added the cranelift label to Issue #12811.
s0me0ne-unkn0wn edited issue #12811:
Summary
When compiling large functions targeting riscv64gc with compressed instructions (Zca) enabled,
emit_veneer()panics because the veneer is placed too far from the originalC.J.The island emission deadline mechanism is supposed to force island emission before any label reference goes out of range, but, presumably, the deadline calculation doesn't account for the very small range of
C.Jwhen traps and constants are flushed before veneers — these can push the veneer past the 2 KiB limit.
.clifTest CaseSteps to Reproduce
$ clif-util test rvcjump_bug_reduced.clifExpected Results
Success
Actual Results
thread 'worker #0' panicked at cranelift/codegen/src/isa/riscv64/inst/mod.rs:1759:9: RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [2026-03-20T19:04:21Z ERROR cranelift_filetests::concurrent] FAIL: panicked in worker #0: RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range. FAIL rvcjump_bug_reduced.clif: panicked in worker #0: RVCJump offset '2048' use_offset:'7416' label_offset:'9464' must not exceed max range. 1 tests Error: 1 failureVersions and Environment
Cranelift version or commit: 0.122.0
Operating system: Linux Manjaro
Architecture: x86_64 cross-compiling to riscv64gc
alexcrichton added the cranelift:area:riscv64 label to Issue #12811.
cfallin commented on issue #12811:
Thanks for the report! I'll take a look at fixing this early next week. FWIW, it appears that the particular minimized example doesn't hit the issue on
main, but does on the corresponding Cranelift versions for Wasmtime 36.0 and 24.0 (LTS releases); I bisected the "started working" point to the upgrade to newest regalloc2, but that's possibly just because of a shift in code size due to different spills/moves and I suspect the root issue is still present in the riscv64 backend.
Last updated: Mar 23 2026 at 16:19 UTC