Stream: git-wasmtime

Topic: wasmtime / issue #12811 Cranelift: riscv64: C.J veneer ra...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2026 at 19:17):

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 original C.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.J when traps and constants are flushed before veneers — these can push the veneer past the 2 KiB limit.

.clif Test Case

rvcjump_bug_reduced.clif.gz

Steps to Reproduce

$ clif-util test rvcjump_bug_reduced.clif

Expected 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 failure

Versions and Environment

Cranelift version or commit: 0.122.0

Operating system: Linux Manjaro

Architecture: x86_64 cross-compiling to riscv64gc

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2026 at 19:17):

s0me0ne-unkn0wn added the bug label to Issue #12811.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2026 at 19:17):

s0me0ne-unkn0wn added the cranelift label to Issue #12811.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2026 at 19:19):

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 original C.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.J when traps and constants are flushed before veneers — these can push the veneer past the 2 KiB limit.

.clif Test Case

rvcjump_bug_reduced.clif.gz

Steps to Reproduce

$ clif-util test rvcjump_bug_reduced.clif

Expected 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 failure

Versions and Environment

Cranelift version or commit: 0.122.0

Operating system: Linux Manjaro

Architecture: x86_64 cross-compiling to riscv64gc

view this post on Zulip Wasmtime GitHub notifications bot (Mar 21 2026 at 15:05):

alexcrichton added the cranelift:area:riscv64 label to Issue #12811.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 21 2026 at 15:40):

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