aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRandy Reddig <[email protected]>2024-10-05 02:36:47 +0200
committerGitHub <[email protected]>2024-10-04 17:36:47 -0700
commit453a1d35c315cb4b2519c86e4d53a7699bbcdea2 (patch)
tree0d8c7e1f0f7e6466eea25e661d101c64e1aacdc3 /src
parent9da8b5c786880e47f6f96b82be7c410af6f9011b (diff)
downloadtinygo-453a1d35c315cb4b2519c86e4d53a7699bbcdea2.tar.gz
tinygo-453a1d35c315cb4b2519c86e4d53a7699bbcdea2.zip
compiler, runtime: enable go:wasmexport for wasip2 (#4499)
* compiler: prefer go:wasmexport over go:export * runtime, targets/wasip2: enable -buildmode=c-shared for wasip2 * runtime: rename import from wasi_run to wasiclirun (PR feedback)
Diffstat (limited to 'src')
-rw-r--r--src/runtime/runtime_wasip2.go (renamed from src/runtime/runtime_wasm_wasip2.go)18
-rw-r--r--src/runtime/runtime_wasmentry.go2
2 files changed, 12 insertions, 8 deletions
diff --git a/src/runtime/runtime_wasm_wasip2.go b/src/runtime/runtime_wasip2.go
index 57e6623d3..ba8f52100 100644
--- a/src/runtime/runtime_wasm_wasip2.go
+++ b/src/runtime/runtime_wasip2.go
@@ -6,18 +6,19 @@ import (
"unsafe"
"internal/wasi/cli/v0.2.0/environment"
+ wasiclirun "internal/wasi/cli/v0.2.0/run"
monotonicclock "internal/wasi/clocks/v0.2.0/monotonic-clock"
+
+ "internal/cm"
)
type timeUnit int64
-//export wasi:cli/[email protected]#run
-func __wasi_cli_run_run() uint32 {
- // These need to be initialized early so that the heap can be initialized.
- heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
- heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
- run()
- return 0
+func init() {
+ wasiclirun.Exports.Run = func() cm.BoolResult {
+ callMain()
+ return false
+ }
}
var args []string
@@ -51,3 +52,6 @@ func sleepTicks(d timeUnit) {
func ticks() timeUnit {
return timeUnit(monotonicclock.Now())
}
+
+func beforeExit() {
+}
diff --git a/src/runtime/runtime_wasmentry.go b/src/runtime/runtime_wasmentry.go
index 5a135f428..7bb1e1b44 100644
--- a/src/runtime/runtime_wasmentry.go
+++ b/src/runtime/runtime_wasmentry.go
@@ -1,4 +1,4 @@
-//go:build tinygo.wasm && !wasip2 && !js
+//go:build tinygo.wasm && !js
package runtime