golang wasm:Remove the content of golang compilation wasm import wasi_snapshot_preview1

91 Views Asked by At

When I use Golang to compile into wasm, (import "wasi_snapshot_preview1" "fd_write" (func $runtime.fd_write (type 2))) will be introduced, but the environment running wasm does not support the wasi_snapshot_preview1 module. How to compile Remove the module wasi_snapshot_preview1?

the main.go:

package main
func main() {
    
}

build wasm cmd:

GOOS=wasip1 GOARCH=wasm go build -o main.wasm main.go

the convert wasm to wat file:

 wasm2wat main.wasm -o main.wat

the wat file

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32)))
  (type (;2;) (func (param i32 i32 i32 i32) (result i32)))
  (type (;3;) (func (param i32 i32)))
  (type (;4;) (func (param i32 i32) (result i32)))
  (type (;5;) (func (result i32)))
  (type (;6;) (func (param i32) (result i32)))
  (type (;7;) (func (param i32 i32 i32)))
  (type (;8;) (func (param i32 i32 i32 i32)))
  (import "wasi_snapshot_preview1" "fd_write" (func $runtime.fd_write (type 2))) //expcting don`t import 
.....)

I expect that the compiled wasm file does not contain the module wasi_snapshot_preview1

0

There are 0 best solutions below