tinygo
tinygo copied to clipboard
`wasm-unknown` target doesn't define `memset` or `memcpy`
Hello, I was trying out the new wasm-unknown target and found that it doesn't seem to be able to compile applications that require memset or memcpy.
I compiled tinygo from source on commit 377415a6c3158d5cefe8cd46c592b144053593aa using llvm 16. With main.go:
package main
func main() {
}
//go:export run
func run() byte {
var arg []byte
for i := 0; i < int(100); i++ {
arg = append(arg, 0)
}
return arg[5]
}
I get the following error:
❯ tinygo build -target=wasm-unknown main.go
wasm-ld-16: error: lto.tmp: undefined symbol: memset
wasm-ld-16: error: lto.tmp: undefined symbol: memcpy
error: failed to link /tmp/tinygo826502402/main: exit status 1
I tried enabling the bulk memory feature in targets/wasm-unknown.json:
"llvm-target": "wasm32-unknown-unknown",
"cpu": "generic",
- "features": "+mutable-globals,+nontrapping-fptoint,+sign-ext,-bulk-memory",
+ "features": "+mutable-globals,+nontrapping-fptoint,+sign-ext,+bulk-memory",
"build-tags": ["tinygo.wasm", "wasm_unknown"],
"goos": "linux",
"default-stack-size": 4096,
"cflags": [
- "-mno-bulk-memory",
"-mnontrapping-fptoint",
"-msign-ext"
],
to see if they'd get compiled to mem.init and mem.copy respectively and that does seem to work.
Is there an easy way to enable the bulk memory feature without forking the repo?
This is related to #4176 and #4169.
❯ tinygo build -target=wasm-unknown main.go wasm-ld-16: error: lto.tmp: undefined symbol: memset wasm-ld-16: error: lto.tmp: undefined symbol: memcpy error: failed to link /tmp/tinygo826502402/main: exit status 1
This is still an issue, so reopening. After #4176 gets merged, this should be easy to add.
Is there an easy way to enable the bulk memory feature without forking the repo?
Not at the moment (though the -llvm-features flag might help). Ideally we'd have either a GOWASM environment variable or maybe a -cpu flag that sets the supported wasm support level (MVP, wasm 2.0, etc).
This was released with v0.32.0 so now closing. Thank you everyone!