Uh oh!
There was an error while loading. Please reload this page.
Make HelloWorld run on wasm with core[wasm]run - #119640
Conversation
And add override pinvoke to resolve entrypoints in static bundle
Tagging subscribers to this area: @mangod9 |
There was a problem hiding this comment.
Pull Request Overview
This PR enables HelloWorld console applications to run on WebAssembly (WASM) using the corewasmrun host by implementing PInvoke support for statically linked native libraries.
- Adds PInvoke override mechanism to resolve native function calls in static WASM binaries
- Links System.Native statically with WASM development hosts (corerun and corewasmrun)
- Updates PE image handling to support flat layouts required for WASM
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/System.Native/entrypoints.c | Conditionally excludes WASM-unsupported network event functions from entry points |
| src/native/libs/System.Native/CMakeLists.txt | Includes entrypoints.c in WASM static builds by removing browser target exclusion |
| src/coreclr/vm/wasm/helpers.cpp | Adds placeholder implementation for timezone data function to avoid dependency |
| src/coreclr/vm/peimage.inl | Updates PE image layout check to support flat layouts when PEIMAGE_FLAT_LAYOUT_ONLY is enabled |
| src/coreclr/hosts/corewasmrun/corewasmrun.cpp | Implements complete HelloWorld execution with proper initialization, assembly execution, and shutdown |
| src/coreclr/hosts/corewasmrun/CMakeLists.txt | Links System.Native statically and includes shared WASM PInvoke override code |
| src/coreclr/hosts/corerun/corerun.wasm.hpp | Header file declaring WASM PInvoke override initialization function |
| src/coreclr/hosts/corerun/corerun.wasm.cpp | Implements PInvoke override mechanism to resolve System.Native functions in static builds |
| src/coreclr/hosts/corerun/corerun.cpp | Integrates WASM PInvoke override initialization into corerun host |
| src/coreclr/hosts/corerun/CMakeLists.txt | Links System.Native statically and includes WASM-specific source for corerun |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Link devel hosts with System.Native on wasm
Add PInvoke override to resolve entrypoints in static wasm binary
Update
PEImage::HasLoadedLayout()to check for flat image whenPEIMAGE_FLAT_LAYOUT_ONLYis enabledNote: it also depends on changes in #119591
To try it:
dotnet new consoletemplate)https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/wasm.md#testing-the-runtime
https://github.com/dotnet/runtime/blob/main/docs/workflow/building/coreclr/wasm.md#building-coreclr-for-webassembly-1