runtime/wasm: add WASI single-worker scheduler (based on #2192, #2208) - #2197
Draft
cpunion wants to merge 19 commits into
Draft
runtime/wasm: add WASI single-worker scheduler (based on #2192, #2208)#2197cpunion wants to merge 19 commits into
cpunion wants to merge 19 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Jul 28, 2026
cpunion
force-pushed
the
codex/wasm-wasi-single-worker
branch
from
July 28, 2026 14:12
24020c3 to
e3e8ea8
Compare
…/wasm-wasi-single-worker
…orker-asyncify-scheduler # Conflicts: # internal/build/source_patch_test.go
…/wasm-wasi-single-worker
…orker-asyncify-scheduler # Conflicts: # runtime/internal/runtime/z_default.go
…/wasm-wasi-single-worker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #2192 and #2208.
Part of #2152.
Problem
GOOS=wasip1 GOARCH=wasm llgo buildcan produce a module after #2192, but goroutines still select the pthread runtime. The resulting executable imports shared host memory and WASI pthread facilities, so ordinary single-worker Wasmtime execution cannot run Go scheduler behavior.Implementation
LLGO_WASI_THREADS=1compatibility mode.main.mainas the first schedulable task while keeping the host entry on the system stack.runtime.EnsureLocalInitializerafter compiler/runtime: add //llgo:tls and //llgo:gls package variables #2079.The implementation is intentionally limited to the scheduler/context foundation. Channel blocking, timers and host async integration, wasm GC integration, root/safepoint work, and optional WASI Preview2 support remain follow-up work tracked by #2152.
Validation
Bounded locally with
GOMAXPROCS=2,-p=1, and a 15 GiB ceiling:-O0,-O3, and ThinLTO builds; the final module validates and has no default pthread/shared-memory imports.LLGO_WASI_THREADS=1still builds the historical pthread/shared-memory artifact._demo/c/hellocP1 build/execution path, Go 1.26.5 tests, and Go 1.24.2 host tests pass.runtime.printany; the same failure reproduces on the unmodified runtime/wasm: add single-worker Asyncify scheduler #2192 base.Independent diff over #2192 and #2208: 26 files, +1,199/-35. This includes the focused post-link lifecycle coverage added after the initial review.