You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[wasi] Embed the wasi:http component type in an object file instead of passing --component-type #137699
System.Net.Http's WasiHttpHandler imports wasi:http 0.2.8 directly from managed code. On its own, the linked core module doesn't give wasm-component-ld enough to reconstruct the component types, so each wasi link path passes the world explicitly with -Wl,--component-type,WasiHttpWorld_component_type.wit:
That means shipping the .wit in the runtime packs and keeping the same plumbing in every toolchain.
Native toolchains embed the type information in an object file instead. wasi-libc's libc.a contains wasip2_component_type.o, generated by wit-bindgen's C generator with a component-type: custom section. It also defines __component_type_object_force_link_wasip2, which wasip2.c.obj references, so the object is only linked when the bindings are. wasm-component-ld then picks up the types with no extra flags.
Proposal: do the same for wasi:http, for both CoreCLR and NativeAOT.
Generate the encoded component type alongside the existing bindings. generate-wasi-http-bindings.sh already runs wit-bindgen; the C generator or wasm-tools component embed could produce the section, checked in as a byte array in a C source file.
Compile it into libSystem.Native.a together with a force-link function.
Have WasiHttpHandler call that function through a System.Native P/Invoke, so the object is linked only when the handler survives trimming. That works for NativeAOT, where System.Native is a direct P/Invoke, and for the CoreCLR relink, through its generated P/Invoke table.
Then remove the --component-type flags and NetCoreAppComponentType items, and stop shipping the .wit in the packs.
Open questions:
How best to produce the encoded section from the existing generator. The repo build has no wasm-tools or wit-bindgen, so the output has to be generated by the script and checked in.
Whether the force-link reference reaches the object through the CoreCLR P/Invoke table in every configuration.
Activity
dotnet-policy-service commentedon Nov 16, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Nov 16, 2026
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.