]> Cypherpunks repositories - gostls13.git/commit
cmd/link, runtime: support library mode on wasip1
authorCherry Mui <cherryyz@google.com>
Thu, 8 Aug 2024 22:45:18 +0000 (18:45 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 13 Aug 2024 21:27:50 +0000 (21:27 +0000)
commit0b1494f5d24afe7725e724905173b910b83e24e7
treeefd0de9f463072e097482af6f63d4c9088cd4376
parent0253c0f4acdf9f7a2930609f55d24b334fa7d3c2
cmd/link, runtime: support library mode on wasip1

This CL adds support of "library", i.e. c-shared, build mode on
wasip1. When -buildmode=c-shared is set, it builds a Wasm module
that is intended to be used as a library, instead of an executable.
It does not have the _start function. Instead, it has an
_initialize function, which initializes the runtime, but not call
the main function.

This is similar to the c-shared build mode on other platforms. One
difference is that unlike cgo callbacks, where Ms are created on-
demand, on Wasm we have only one M, so we just keep the M (and the
G) for callbacks.

For #65199.

Change-Id: Ieb21da96b25c1a9f3989d945cddc964c26f9085b
Reviewed-on: https://go-review.googlesource.com/c/go/+/604316
Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
14 files changed:
src/cmd/dist/test.go
src/cmd/go/internal/load/pkg.go
src/cmd/internal/obj/wasm/wasmobj.go
src/cmd/link/internal/ld/config.go
src/cmd/link/internal/ld/symtab.go
src/cmd/link/internal/wasm/asm.go
src/internal/platform/supported.go
src/runtime/asm_wasm.s
src/runtime/lock_js.go
src/runtime/proc.go
src/runtime/rt0_js_wasm.s
src/runtime/rt0_wasip1_wasm.s
src/runtime/stubs_nonwasm.go [new file with mode: 0644]
src/runtime/stubs_wasm.go [new file with mode: 0644]