[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
Draft
pavelsavara wants to merge 9 commits into
Draft
[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997pavelsavara wants to merge 9 commits into
pavelsavara wants to merge 9 commits into
Conversation
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Mono WASI toolchain (WASI SDK / wasmtime) and regenerates the WASIp2 (0.2.8) component-model bindings used by CoreLib and the WASI HTTP handler. It also updates the WASI socket event loop plumbing to match wasi-libc’s new descriptor-table layout and lazy pollable creation, cleans up obsolete Node.js run scripts, and adjusts tests for unsupported WASI scenarios.
Changes:
- Upgrade toolchain inputs (WASI SDK 33.0, wasmtime 45.0.0) and remove Node-based emulation/run-script generation.
- Regenerate WASIp2 bindings to
0.2.8and update managed call sites accordingly. - Update WASI socket descriptor resolution + pollable subscription (native + managed) and adjust System.Net tests to skip unsupported features on WASI.
Reviewed changes
Copilot reviewed 68 out of 70 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/System.Native/pal_networking.h | Updates WASI socket descriptor API signature and adds pollable subscription export. |
| src/native/libs/System.Native/pal_networking.c | Implements new WASI descriptor-table probing and lazy pollable subscription helper. |
| src/native/libs/System.Native/entrypoints.c | Exposes the new native entrypoint for managed interop. |
| src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.cs | Updates LibraryImport signatures for the revised native WASI socket APIs. |
| src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.cs | Mirrors updated wasi-libc tcp/udp socket struct layouts and removes obsolete descriptor tagged-union types. |
| src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEngine.Wasi.cs | Uses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables. |
| src/mono/wasi/wasmtime-version.txt | Bumps the pinned wasmtime version. |
| src/mono/wasi/wasi.proj | Removes obsolete -lwasi-emulated-pthread link flag for WASI SDK 33. |
| src/mono/wasi/build/WasiApp.targets | Updates toolchain version check, removes Node run-script generation, and adjusts link flags. |
| eng/native/gen-buildsys.sh | Removes Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI. |
| eng/native/gen-buildsys.cmd | Removes Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows). |
| eng/AcquireWasiSdk.targets | Bumps acquired WASI SDK version to 33.0. |
| eng/testing/tests.wasi.targets | Forces AppBundle generation for WASI test projects (OutputType=Library). |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.wit | Updates WIT imports to WASIp2 0.2.8. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.cs | Updates generated support types for wit-bindgen 0.57.1 output. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.cs | Switches event loop to regenerated 0.2.8 poll/clock APIs. |
| src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.cs | Updates monotonic clock interop usage to 0.2.8. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.sh | Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.ps1 | Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1. |
| src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems | Updates compile item list to new generated file names for 0.2.8. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.Imports.wasi.io.v0_2_8.PollImportsInterop.cs | New generated 0.2.8 poll imports interop. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.Imports.wasi.io.v0_2_8.IPollImports.cs | New generated 0.2.8 poll imports API surface. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.Imports.wasi.clocks.v0_2_8.MonotonicClockImportsInterop.cs | New generated 0.2.8 clock imports interop. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.Imports.wasi.clocks.v0_2_8.IMonotonicClockImports.cs | New generated 0.2.8 clock imports API surface. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.imports.wasi.io.v0_2_0.PollInterop.cs | Removes old generated 0.2.0 poll interop. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.imports.wasi.io.v0_2_0.IPoll.cs | Removes old generated 0.2.0 poll API. |
| src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPollWorld.wit.imports.wasi.clocks.v0_2_0.MonotonicClockInterop.cs | Removes old generated 0.2.0 clock interop. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs | Updates generated support types for wit-bindgen 0.57.1 output. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.wit | Updates WIT package/interface versions from 0.2.0 to 0.2.8. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.cs | Updates outgoing-handler invocation to regenerated 0.2.8 API surface. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.cs | Updates conversions and error-code mapping to new generated enum/tag conventions. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.cs | Updates stream handling to regenerated 0.2.8 stream error tags. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.cs | Updates stream handling imports to regenerated 0.2.8 API names. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.sh | Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.ps1 | Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1. |
| src/libraries/System.Net.Http/src/System.Net.Http.csproj | Updates compile include list to new generated 0.2.8 files. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.Imports.wasi.io.v0_2_8.* | Adds new generated 0.2.8 io/poll/streams/error interop surfaces. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.Imports.wasi.http.v0_2_8.* | Adds new generated 0.2.8 http types/outgoing-handler interop surfaces. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.Imports.wasi.clocks.v0_2_8.* | Adds new generated 0.2.8 clocks interop surfaces. |
| src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld.wit.imports.v0_2_0. | Removes old generated 0.2.0 HTTP/io/clocks interop surfaces. |
| src/libraries/System.Net.Http/tests/FunctionalTests/SocksProxyTest.cs | Skips proxy tests on WASI where handler support is absent. |
| src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs | Adds WASI skips for unsupported SocketsHttpHandler scenarios. |
| src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.cs | Skips ConnectCallback scenarios on WASI. |
| src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs | Marks known-flaky metrics tests as ActiveIssue on WASI. |
| src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.cs | Skips/marks unsupported or flaky scenarios on WASI. |
| src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs | Skips unsupported synchronous send / version-selection scenarios on WASI. |
| src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs | Skips mini-stress scenarios that require System.Net.Security on WASI. |
| src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.cs | Avoids cert-validation callback configuration on WASI. |
| src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs | Skips proxy tests on WASI handler. |
| src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs | Skips authentication/preauth tests on WASI handler. |
| src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.cs | Skips DualMode tests on WASI. |
| src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.cs | Skips Socket.Blocking tests on WASI. |
This was referenced Jun 5, 2026
Member
Author
|
/azp list |
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Summary
This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the
0.2.8interfaces. It also fixesSystem.Net.Socketsto work with thenew wasi-libc descriptor-table layout, removes the obsolete Node.js run scripts, and disables
HTTP/socket test scenarios that the WASI handler does not support.
wasi:io,wasi:http,wasi:clocks)Motivation
The
0.2.0snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind thecurrent ecosystem. wasi-libc also changed its internal socket descriptor table from a tagged
union to a "fat pointer" + vtable design and now creates the embedded pollables lazily, which
broke the existing
System.Net.Socketsevent loop. This brings the toolchain current andrestores socket functionality on the new wasi-libc.
Changes
Toolchain / build infrastructure
eng/AcquireWasiSdk.targets,src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to33.0. The version check now matches by prefix (StartsWith) so future patch releases of thesame major are accepted.
src/mono/wasi/wasmtime-version.txt: bump wasmtime to45.0.0.eng/native/gen-buildsys.cmd/gen-buildsys.sh: drop the Node.js-basedCMAKE_CROSSCOMPILING_EMULATOR(the--experimental-wasi-unstable-preview1Node path is nolonger used).
src/mono/wasi/wasi.proj,WasiApp.targets: stop linking-lwasi-emulated-pthread, which isno longer provided / needed by WASI SDK 33.0.
Run-script cleanup
WasiApp.targets: remove the_WasmGenerateNodeScriptstarget and the generatednode.mjs/run-node.shfiles. WASI apps run under wasmtime via the existing_GenerateRunWasmtimeScripttarget.Test AppBundle generation
eng/testing/tests.wasi.targets: forceWasmGenerateAppBundle=truefor WASI test projects.Test projects are
OutputType=Library, for which the property defaults tofalse; unlikebrowser there is no SDK that bundles via static web assets, so the in-tree
WasiAppBuildermust run to populate the AppBundle.
Regenerated WASIp2 bindings (
0.2.0→0.2.8)System.Net.Http/.../WasiHttpHandler/*andSystem.Private.CoreLib/.../Threading/Wasi/*:regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
(
Method.get()→Method.Get(),ErrorCode.DNS_TIMEOUT→ErrorCode.Tags.DnsTimeout,Result.ok/err→Ok/Err,IPoll/ITypes→IPollImports/ITypesImports, etc.).WasiHttpInterop.cs,WasiHttpHandler.cs,WasiInputStream.cs,WasiOutputStream.cs,WasiEventLoop.cs,TimerQueue.Wasi.cs) updated to the new API names..witworld files and thegenerate-wasi-*-bindings.{ps1,sh}scripts updated to pin0.2.8and wit-bindgen0.57.1..csproj/.projitemscompile lists updated to the new generated file names.Sockets on the new wasi-libc descriptor table
wasi-libc replaced the tagged-union descriptor entry with a fat pointer (
{ void* data; descriptor_vtable_t* vtable; }) and now creates the per-socket pollables lazily.src/native/libs/System.Native/pal_networking.c/.h/entrypoints.c:SystemNative_GetWasiSocketDescriptornow returns the descriptordatapointer plus asocketType(1= TCP/stream,2= UDP/datagram) discriminated viagetsockopt(SO_TYPE),since the vtable that previously identified the kind is a private static symbol.
SystemNative_WasiSubscribeSocketPollablelazily calls the wasi-libcsubscribeimports to materialize a pollable handle on demand.
Interop.SocketEvent.cs: matchingLibraryImportsignature updates.SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libctcp_socket_t/udp_socket_t(field reorder,bool→byte,error_codewidened toint, trailing timeout fields). The obsoletedescriptor_table_entry_*types are removed.SocketAsyncEngine.Wasi.cs:BeforePollHookdiscriminates on the nativesocketTypeanduses a new
EnsurePollablehelper that subscribes lazily (storing the handle back sowasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.
Test scenario adjustments
System.Net.Httptests: added[SkipOnPlatform(TestPlatforms.Wasi, …)]for scenarios theWASI handler does not support (authentication, pre-authentication, proxy, client/server
certificates, decompression, sync
Send, version selection,MaxConnectionsPerServer,SOCKS proxy, zero-byte read /
ConnectCallback, mini-stress /System.Net.Security,SocketsHttpHandlerargument-validation cases). Several flaky cancellation/metrics cases aremarked
[ActiveIssue(98957, TestPlatforms.Wasi)].System.Net.Socketstests: skipSocket.Blockingand DualMode scenarios unsupported on WASI.