deepflow icon indicating copy to clipboard operation
deepflow copied to clipboard

[FR] Improve the documentation for the wasm plugin

Open wuzongling opened this issue 1 year ago • 0 comments

Search before asking

  • [X] I had searched in the issues and found no similar feature requirement.

Description

tinygo build -o wasm.wasm -gc=custom -tags=custommalloc -target=wasi -panic=trap -scheduler=none -no-debug ./main.go 这个命令在gonland 1.9 tinygo tinygo version 0.29.0 darwin/amd64 (using go version go1.18.10 and LLVM version 15.0.0) 是会运行报错的:

panic: missing core function "runtime.free"

goroutine 67 [running]: github.com/tinygo-org/tinygo/transform.Optimize({0x7f57a00c7340?}, 0xc000158510, 0x2, 0x844759?, 0x5) /__w/tinygo/tinygo/transform/optimizer.go:70 +0xdf5 github.com/tinygo-org/tinygo/builder.optimizeProgram({0x7f57a00c7340?}, 0xc000158510) /__w/tinygo/tinygo/builder/build.go:1068 +0x13f github.com/tinygo-org/tinygo/builder.Build.func5(0xc00afae300) /__w/tinygo/tinygo/builder/build.go:572 +0x61d github.com/tinygo-org/tinygo/builder.runJob(0xc00afbb980, 0x0?) /__w/tinygo/tinygo/builder/jobs.go:222 +0x4d created by github.com/tinygo-org/tinygo/builder.runJobs in goroutine 1 /__w/tinygo/tinygo/builder/jobs.go:123 +0x5bd

    如果goland 版本是1.8 编译后的文件会多了random_get的定义,执行wasm 是就会出现 unknown import: `wasi_snapshot_preview1::random_get` has not been defined错误
     
  goland 1.9 版本执行tinygo  build -o wasm.wasm  -target wasi  -panic=trap -scheduler=none -no-debug ./http.go 是可以编译运行成功的。 

所以社区可以完善wasm 编译时指定的goland tinygo 版本,也可以多一个tinygo docker 编译的方式

Use case

No response

Related issues

No response

Are you willing to submit a PR?

  • [X] Yes I am willing to submit a PR!

Code of Conduct

wuzongling avatar Apr 12 '24 07:04 wuzongling