compiler: conform to latest iteration of wasm types proposal (#4501)

compiler: align with current wasm types proposal

https://github.com/golang/go/issues/66984

- Remove int and uint as allowed types in params, results, pointers, or struct fields
- Only allow small integers in pointers, arrays, or struct fields
- enforce structs.HostLayout usage per wasm types proposal
https://github.com/golang/go/issues/66984
- require go1.23 for structs.HostLayout
- use an interface to check if GoVersion() exists
This permits TinyGo to compile with Go 1.21.
- use goenv.Compare instead of WantGoVersion
- testdata/wasmexport: use int32 instead of int
- compiler/testdata: add structs.HostLayout
- compiler/testdata: improve tests for structs.HostLayout
This commit is contained in:
Randy Reddig
2024-10-22 18:05:04 +02:00
committed by GitHub
parent 3dcac3b539
commit 24c11d4ba5
4 changed files with 72 additions and 23 deletions
+3 -3
View File
@@ -18,16 +18,16 @@ func hello() {
}
//go:wasmexport add
func add(a, b int) int {
func add(a, b int32) int32 {
println("called add:", a, b)
return a + b
}
//go:wasmimport tester callOutside
func callOutside(a, b int) int
func callOutside(a, b int32) int32
//go:wasmexport reentrantCall
func reentrantCall(a, b int) int {
func reentrantCall(a, b int32) int32 {
println("reentrantCall:", a, b)
result := callOutside(a, b)
println("reentrantCall result:", result)