Repository navigation
[wasi] Supply the wasi:http component type to NativeAOT links - #137694
Conversation
System.Net.Http's WasiHttpHandler imports wasi:[email protected] from core wasm. wasm-component-ld can't rebuild the resource types from core imports alone and fails at [resource-drop]fields unless the world is passed via --component-type. Mono, CoreCLR relink and corerun pass WasiHttpWorld_component_type.wit; the NativeAOT Wasm targets did not, and the CoreCLR/NativeAOT wasi runtime packs never shipped the .wit. - Ship WasiHttpWorld_component_type.wit in the CoreCLR and NativeAOT wasi-wasm runtime packs (liveBuilds) and stage it into the in-tree runtime pack (build-native.proj). - Pass -Wl,--component-type for it from Microsoft.NETCore.Native.Wasm.targets when present. Unused world imports are dropped from the component, so apps that don't use HttpClient are unaffected; app-supplied --component-type overlays still compose. - Add a wasi-only NativeAOT smoke test that issues an HttpClient request. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…links build-native.proj copies WasiHttpWorld_component_type.wit into the native artifacts dir for every wasi build, so the existing native globs put it in the runtime packs. The NativeAOT Wasm targets error out when it is missing instead of producing an untyped wasi:http link failure. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
The owning library now binplaces WasiHttpWorld_component_type.wit into the runtime pack native dir and the native artifacts dir, following the System.Net.Quic NativeBinPlaceItem pattern, instead of build-native.proj reaching into the library's source tree. Co-authored-by: Copilot App <[email protected]>
- Pass component types through a NetCoreAppComponentType item group. - Drop the missing-file error. - Remove the WasiHttp smoke test; src/libraries testing on wasi will cover it. Co-authored-by: Copilot App <[email protected]>
|
Side remark: native toolchains seem to be including this in object files. Should this be in an object file? |
Good question, I will check. |
There was a problem hiding this comment.
🔵 Needs a closer look
Runtime-pack staging and component linking remain unverified; publishing from the produced NativeAOT WASI pack with and without HttpClient is needed to confirm WIT placement, import resolution, and unused wasi:http import removal.
No open issues 🎉
What changed in this PR
This PR supplies the wasi:http component type needed to link NativeAOT WASI apps using HttpClient, aligning NativeAOT linking with the existing CoreCLR approach.
Changes:
- Binplaces
WasiHttpWorld_component_type.witinto runtime-pack and native-artifact directories. - Includes
.witfiles in shared runtime-pack native-file collection. - Passes component-type items to the NativeAOT WASM linker.
| File | Description |
|---|---|
src/libraries/System.Net.Http/src/System.Net.Http.csproj |
Adds WASI HTTP component-type binplacement. |
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Wasm.targets |
Registers the HTTP component type and supplies linker arguments. |
eng/liveBuilds.targets |
Moves .wit collection into the shared native-artifact list. |
Review effort: Balanced
Opened #137699 because we don't currently install the tooling to do it, but I will take care of it in a follow-up |
…t types Mirror the NativeAOT wasi targets: declare framework WIT worlds as NetCoreAppComponentType items and transform them into --component-type link flags against the runtime pack native dir. System.Net.Http now binplaces the .wit into the runtime pack, so drop the source-tree fallback and the missing-file error. Co-authored-by: Copilot App <[email protected]>
|
Did the same small cleanup to coreclr targets. |
NativeAOT wasi-wasm apps that use
HttpClientfail to link:WasiHttpHandlerimports wasi:http from core wasm. wasm-component-ld can't work out the wasi:http resource types from those imports alone; it needsWasiHttpWorld_component_type.wit. The CoreCLR relink and corerun already pass it, but the NativeAOT targets did not, and the CoreCLR/NativeAOT wasi runtime packs never shipped the file.System.Net.Http.csprojbinplaces the.witfor wasi (same pattern as System.Net.Quic's native files), andliveBuilds.targetspicks up*.witfrom the native artifacts dir, so it ships in the runtime packs.Microsoft.NETCore.Native.Wasm.targetspasses eachNetCoreAppComponentTypeitem as-Wl,--component-type. Apps that don't use wasi:http end up with no wasi:http imports.WasiApp.CoreCLR.targetsuses the sameNetCoreAppComponentTypeitem for the CoreCLR relink and drops its source-tree fallback and missing-file error.Relates to #132798
Note
This PR description was generated with GitHub Copilot.