Description
New to TinyGo here.
I need a series of math functions in WebAssembly. These functions can all be called discretely by Javascript and they are completely self-sufficient: they need no other runtime features like garbage collection, debug information, etc. (They likely will not even need an import object defined in Javascript.)
I made a short example program, findJD.go
.
When I compile like this:
tinygo build -o tinygo.wasm -target=wasm -gc=none -scheduler=none -no-debug ./findJD.go
And then convert the WASM to WAT to look at the output (using another tool), I can see that the following is created (among other things):
(import "wasi_snapshot_preview1" "fd_write" (func $fimport$0 (param i32 i32 i32 i32) (result i32)))
(import "env" "runtime.alloc" (func $fimport$1 (param i32 i32 i32 i32) (result i32)))
(import "env" "main.main" (func $fimport$2 (param i32 i32)))
(memory $0 2)
(data (i32.const 65536) "panic: runtime error: index out of rangeunimplemented: reallocunimplemented: posix_memalignunimplemented: aligned_allocunimplemented: malloc_usable_size")
(data (i32.const 65688) "\a4\00\01\00\00\00\00\00")
(table $0 1 1 funcref)
(global $global$0 (mut i32) (i32.const 65536))
(export "memory" (memory $0))
(export "malloc" (func $5))
(export "free" (func $6))
(export "calloc" (func $7))
(export "realloc" (func $8))
(export "posix_memalign" (func $9))
(export "aligned_alloc" (func $10))
(export "malloc_usable_size" (func $11))
(export "_start" (func $12))
(export "findJD" (func $13))
Simply put, the only thing that I am going to actually use is:
(export "findJD" (func $13))
For reference, if I write my example program in WAT by hand, compile it and convert back to WAT, I get:
(type $i32_i32_f64_=>_f64 (func (param i32 i32 f64) (result f64)))
(export "findJD" (func $0))
I want to get as close to that simplicity as I can. How do I achieve this?