[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc - #128997

Merged
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono
Jun 7, 2026
Merged

[WASI][Mono] Upgrade WASI SDK / wasmtime / WASIp2 to 0.2.8 and fix sockets for new wasi-libc#128997
pavelsavara merged 12 commits into
dotnet:mainfrom
pavelsavara:wasisdk-mono

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

This branch upgrades the Mono WASI toolchain and regenerates the WASIp2 component-model
bindings against the 0.2.8 interfaces. It also fixes System.Net.Sockets to work with the
new 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.

ComponentOldNew
WASI SDK25.033.0
wasmtime27.0.045.0.0
WASIp2 interfaces (wasi:io, wasi:http, wasi:clocks)0.2.00.2.8
wit-bindgen (C#)0.32.00.57.1

Motivation

The 0.2.0 snapshot of the WASI SDK and the WASIp2 interfaces had drifted well behind the
current 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.Sockets event loop. This brings the toolchain current and
restores socket functionality on the new wasi-libc.

Changes

Toolchain / build infrastructure

  • eng/AcquireWasiSdk.targets, src/mono/wasi/build/WasiApp.targets: bump expected WASI SDK to
    33.0. The version check now matches by prefix (StartsWith) so future patch releases of the
    same major are accepted.
  • src/mono/wasi/wasmtime-version.txt: bump wasmtime to 45.0.0.
  • eng/native/gen-buildsys.cmd / gen-buildsys.sh: drop the Node.js-based
    CMAKE_CROSSCOMPILING_EMULATOR (the --experimental-wasi-unstable-preview1 Node path is no
    longer used).
  • src/mono/wasi/wasi.proj, WasiApp.targets: stop linking -lwasi-emulated-pthread, which is
    no longer provided / needed by WASI SDK 33.0.

Run-script cleanup

  • WasiApp.targets: remove the _WasmGenerateNodeScripts target and the generated node.mjs /
    run-node.sh files. WASI apps run under wasmtime via the existing
    _GenerateRunWasmtimeScript target.

Test AppBundle generation

  • eng/testing/tests.wasi.targets: force WasmGenerateAppBundle=true for WASI test projects.
    Test projects are OutputType=Library, for which the property defaults to false; unlike
    browser there is no SDK that bundles via static web assets, so the in-tree WasiAppBuilder
    must run to populate the AppBundle.

Regenerated WASIp2 bindings (0.2.00.2.8)

  • System.Net.Http/.../WasiHttpHandler/* and System.Private.CoreLib/.../Threading/Wasi/*:
    regenerated with wit-bindgen 0.57.1. The new generator changes naming conventions
    (Method.get()Method.Get(), ErrorCode.DNS_TIMEOUTErrorCode.Tags.DnsTimeout,
    Result.ok/errOk/Err, IPoll/ITypesIPollImports/ITypesImports, etc.).
  • Hand-written consumers (WasiHttpInterop.cs, WasiHttpHandler.cs, WasiInputStream.cs,
    WasiOutputStream.cs, WasiEventLoop.cs, TimerQueue.Wasi.cs) updated to the new API names.
  • .wit world files and the generate-wasi-*-bindings.{ps1,sh} scripts updated to pin
    0.2.8 and wit-bindgen 0.57.1.
  • .csproj / .projitems compile 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_GetWasiSocketDescriptor now returns the descriptor data pointer plus a
      socketType (1 = TCP/stream, 2 = UDP/datagram) discriminated via getsockopt(SO_TYPE),
      since the vtable that previously identified the kind is a private static symbol.
    • New SystemNative_WasiSubscribeSocketPollable lazily calls the wasi-libc subscribe
      imports to materialize a pollable handle on demand.
  • Interop.SocketEvent.cs: matching LibraryImport signature updates.
  • SocketPal.Wasi.cs: struct layouts updated to mirror the new wasi-libc
    tcp_socket_t / udp_socket_t (field reorder, boolbyte, error_code widened to
    int, trailing timeout fields). The obsolete descriptor_table_entry_* types are removed.
  • SocketAsyncEngine.Wasi.cs: BeforePollHook discriminates on the native socketType and
    uses a new EnsurePollable helper that subscribes lazily (storing the handle back so
    wasi-libc owns and later drops it) instead of reading a pre-existing pollable handle.

Test scenario adjustments

  • System.Net.Http tests: added [SkipOnPlatform(TestPlatforms.Wasi, …)] for scenarios the
    WASI 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,
    SocketsHttpHandler argument-validation cases). Several flaky cancellation/metrics cases are
    marked [ActiveIssue(98957, TestPlatforms.Wasi)].
  • System.Net.Sockets tests: skip Socket.Blocking and DualMode scenarios unsupported on WASI.

@pavelsavarapavelsavara added this to the 11.0.0 milestone Jun 4, 2026
@pavelsavarapavelsavara self-assigned this Jun 4, 2026
CopilotAI review requested due to automatic review settings June 4, 2026 16:52
@pavelsavarapavelsavara added arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm labels Jun 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.8 and 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
FileDescription
src/native/libs/System.Native/pal_networking.hUpdates WASI socket descriptor API signature and adds pollable subscription export.
src/native/libs/System.Native/pal_networking.cImplements new WASI descriptor-table probing and lazy pollable subscription helper.
src/native/libs/System.Native/entrypoints.cExposes the new native entrypoint for managed interop.
src/libraries/Common/src/Interop/Wasi/System.Native/Interop.SocketEvent.csUpdates LibraryImport signatures for the revised native WASI socket APIs.
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Wasi.csMirrors 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.csUses socketType discrimination + lazy pollable subscription to integrate with wasi-libc’s new lazy pollables.
src/mono/wasi/wasmtime-version.txtBumps the pinned wasmtime version.
src/mono/wasi/wasi.projRemoves obsolete -lwasi-emulated-pthread link flag for WASI SDK 33.
src/mono/wasi/build/WasiApp.targetsUpdates toolchain version check, removes Node run-script generation, and adjusts link flags.
eng/native/gen-buildsys.shRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI.
eng/native/gen-buildsys.cmdRemoves Node CMAKE_CROSSCOMPILING_EMULATOR usage for WASI (Windows).
eng/AcquireWasiSdk.targetsBumps acquired WASI SDK version to 33.0.
eng/testing/tests.wasi.targetsForces AppBundle generation for WASI test projects (OutputType=Library).
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/world.witUpdates WIT imports to WASIp2 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiPoll.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/WasiEventLoop.csSwitches event loop to regenerated 0.2.8 poll/clock APIs.
src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Wasi.csUpdates monotonic clock interop usage to 0.2.8.
src/libraries/System.Private.CoreLib/src/System/Threading/Wasi/generate-wasi-poll-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitemsUpdates 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.csNew 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.csNew 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.csNew 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.csNew 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.csRemoves 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.csRemoves 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.csRemoves old generated 0.2.0 clock interop.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.csUpdates generated support types for wit-bindgen 0.57.1 output.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpWorld_component_type.witUpdates WIT package/interface versions from 0.2.0 to 0.2.8.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.csUpdates outgoing-handler invocation to regenerated 0.2.8 API surface.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpInterop.csUpdates conversions and error-code mapping to new generated enum/tag conventions.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiInputStream.csUpdates stream handling to regenerated 0.2.8 stream error tags.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiOutputStream.csUpdates stream handling imports to regenerated 0.2.8 API names.
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/generate-wasi-http-bindings.shUpdates 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.ps1Updates binding generation script to fetch 0.2.8 and wit-bindgen 0.57.1.
src/libraries/System.Net.Http/src/System.Net.Http.csprojUpdates 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.csSkips proxy tests on WASI where handler support is absent.
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds WASI skips for unsupported SocketsHttpHandler scenarios.
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.csSkips ConnectCallback scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.csMarks known-flaky metrics tests as ActiveIssue on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpContentTest.csSkips/marks unsupported or flaky scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.csSkips unsupported synchronous send / version-selection scenarios on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.csSkips mini-stress scenarios that require System.Net.Security on WASI.
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.csAvoids cert-validation callback configuration on WASI.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.csSkips proxy tests on WASI handler.
src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.csSkips authentication/preauth tests on WASI handler.
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketAsyncEventArgsTest.csSkips DualMode tests on WASI.
src/libraries/System.Net.Sockets/tests/FunctionalTests/CreateSocketTests.csSkips Socket.Blocking tests on WASI.

Comment threadsrc/native/libs/System.Native/pal_networking.c
Comment threadsrc/native/libs/System.Native/pal_networking.c
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara marked this pull request as ready for review June 5, 2026 13:33
CopilotAI review requested due to automatic review settings June 5, 2026 13:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 72 changed files in this pull request and generated 5 comments.

Comment threadeng/testing/tests.wasi.targets
Comment threadsrc/mono/wasi/build/WasiApp.targets
@pavelsavara

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
pavelsavara merged commit e17d74b into dotnet:mainJun 7, 2026
190 of 192 checks passed
@pavelsavara
pavelsavara deleted the wasisdk-mono branch June 7, 2026 08:19
lewing added a commit to lewing/runtime that referenced this pull request Jun 7, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pavelsavara added a commit to dotnet/dotnet-buildtools-prereqs-docker that referenced this pull request Jun 9, 2026
lewing added a commit to lewing/runtime that referenced this pull request Jun 23, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 25, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lewing added a commit to lewing/runtime that referenced this pull request Jun 30, 2026
Reapplies the build-system subset of the WASI-target seed commit from
PR dotnet#128465 (2d2e1fb), adapted to the current pr/128997 base:
- eng/Subsets.props: register TargetsWasi as a CoreCLR-supported OS,
default flavor + DefaultCoreClrSubsets (dropped provision.wasisdk —
there is no AcquireWasiSdk.proj; SDK acquisition is wired through
runtime.proj and native.wasm.targets instead).
- eng/native.wasm.targets: import AcquireWasiSdk.targets; mirror the
Browser+CoreCLR ItemGroup for Wasi+CoreCLR (GEN_PINVOKE +
PERFTRACING listen-port disables).
- eng/native/configurecompiler.cmake: emit TARGET_WASI under the unix
branch so it pairs with TARGET_BROWSER.
- eng/native/configureplatform.cmake: set CLR_CMAKE_HOST_UNIX +
CLR_CMAKE_TARGET_UNIX for WASI.
- src/coreclr/CMakeLists.txt: add WASI to FEATURE_STANDALONE_GC opt-out;
add the WASI compile-options block (emulated mman/signal/clocks/getpid,
sjlj for now (Phase 6 will switch to native wasm exceptions),
F_DUPFD_CLOEXEC/O_CLOEXEC defines, pal/wasi shim include dir);
exclude WASI from test-watchdog and tools/aot/jitinterface.
- src/coreclr/clrfeatures.cmake: untouched (FEATURE_EVENT_TRACE
condition was reworked upstream — main now enables event_trace for
browser CoreCLR via dotnet#128997, so the seed's exclusion no longer
applies. Leave WASI on the same path; revisit if the WASI build
fails on event_trace).
- src/coreclr/dlls/mscoree/exports.cpp: untouched (seed added debug
fprintfs later reverted in commit 3ca3028).
- src/coreclr/gc/unix/*: untouched (the gc/wasm/ subdir added in
dotnet#127328 already handles WASI; gc/unix is no longer compiled for
wasm targets).
- src/coreclr/runtime.proj: add AcquireWasiSdk to
BuildRuntimeDependsOnTargets for Wasi.
- src/coreclr/tools/CMakeLists.txt: exclude WASI from superpmi.
- src/coreclr/debug/debug-pal/CMakeLists.txt: keep
DEBUG_PAL_REFEREENCE_DIAGNOSTICSERVER off for WASI.
- src/coreclr/debug/debug-pal/unix/twowaypipe.cpp: stub mkfifo() on
WASI (ENOTSUP).
- src/coreclr/pal/src/CMakeLists.txt: skip libunwind on WASM hosts;
exclude debug/debug.cpp and exception/signal.cpp for WASI; skip
coreclrpal_dac libunwind on wasm. (mmap-wasi.c will be added in
Phase 3.)
- src/coreclr/pal/src/configure.cmake: guard pthread checks behind
PTHREAD_LIBRARY (WASI has no pthread); HAVE_SCHED_OTHER_ASSIGNABLE=0
for WASI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 9, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-wasiRelated to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pavelsavara@lewing