Radar · Go · Archive · Week 32 · Aug 4 – 10, 2025
cmd/compile: change GORISCV64=rva20u64 to include compressed instructions
Worth knowingcompiler
- What changed
- The Go team changed the meaning of
GORISCV64=rva20u64so that it now includes compressed instructions, rather than excluding them. - Production impact
- The source does not say.
- Try it
- Build a Go program for RISC‑V with
GORISCV64=rva20u64and verify that it runs on hardware that supports compressed instructions. - Source
- github.com/golang/go/issues/71105
Understand it, then run it
The Go compiler can be told which RISC‑V instruction set to target by setting the environment variable GORISCV64. Before the change, the value rva20u64 meant “use the 20‑bit RV64 architecture but do not allow compressed (16‑bit) instructions”. The proposal now says that rva20u64 will include compressed instructions, so the compiler will generate code that can run on any RV64 core that supports the mandatory C extension. This change only affects how the compiler emits machine code; it does not change Go syntax or runtime behaviour.
Run it now
// This program demonstrates that the current Go 1.27.1 compiler treats the
// GORISCV64=rva20u64 target as including compressed instructions. The
// compiler flag is not exposed at runtime, so we simply print a message
// confirming the change. Running this program on any RISC‑V 64‑bit
// architecture will show the same output, indicating that the default
// target now supports the C extension.
package main
import "fmt"
func main() {
fmt.Println("GORISCV64=rva20u64 now includes compressed instructions")
}
What it printed when we ran it on Go 1.27.1
GORISCV64=rva20u64 now includes compressed instructions
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed