wasm: use wasip1 API for parameter/env passing

Instead of hardcoding the command line parameters and the environment
variables in the binary, pass them at runtime to Node.js and use the
WASIp1 API to retrieve them in wasm_exec.js.

The only real benefit right now is that it becomes possible to change
`go.argv` and `go.env` before running a wasm binary.

This also changes the syscall package for GOOS=js: it now becomes more
like a libc (using wasi-libc), which means error values like
`syscall.EEXIST` will actually match the one returned by the relevant
libc function.

Wasm binary size for packages that import the os package will be
increased somewhat.
This commit is contained in:
Ayke van Laethem
2024-10-30 11:01:21 +01:00
parent 0edeaf657f
commit 8e7a288bb4
12 changed files with 105 additions and 57 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build baremetal || nintendoswitch || js || wasm_unknown
//go:build baremetal || nintendoswitch || wasm_unknown
package syscall