Open
Description
We are working on proving the execution of go-compiled WASM code using zero-knowledge (ZK) (see https://github.com/DelphinusLab/zkWasm). However, the current zkWASM prover cannot support floating point instructions (f32.xxx/f64.xxx). We tried to use go build -gcflags=all=-d=softfloat
and we found most of the FP instructions are translated to INT ones except f64.load
, f64.store
, f64.ceil
, f64.floor
.
Q: Is there a way to support softfloat explicitly for WASM or any flags to fully support softfloat?
Test code (fp.go):
import "math"
func main() {
a := 3.5
b := 2.7
println(math.Ceil(a))
println(math.Floor(a))
println(a / b)
}
Commands
$ go version
go version go1.21.0 linux/amd64
$ GOOS=js GOARCH=wasm go build -gcflags=all=-d=softfloat fp.go
$ wasm2wat fp | grep 'f32\.'
$ wasm2wat fp | grep 'f64\.'
f64.load offset=8
f64.floor
f64.store offset=16
f64.load offset=8
f64.ceil
f64.store offset=16
Metadata
Assignees
Type
Projects
Status
Incoming