[wasm][coreclr] Implement webcil V1 support in WebcilConverter and readers#126709
Merged
radekdoulik merged 1 commit intodotnet:mainfrom Apr 9, 2026
Merged
[wasm][coreclr] Implement webcil V1 support in WebcilConverter and readers#126709radekdoulik merged 1 commit intodotnet:mainfrom
radekdoulik merged 1 commit intodotnet:mainfrom
Conversation
PR dotnet#126388 bumped the shared webcil version from 0 to 1 without updating the WebcilConverter path, breaking all browser-wasm library tests with COR_E_ASSEMBLYEXPECTED errors. Changes: - Add TableBase field to managed WebcilHeader struct (32 bytes for V1) - WebcilConverter: parameterize version (default V0), write V0 (28-byte) or V1 (32-byte) header based on webcilVersion parameter - WebcilReader: read V0 header first (28 bytes), then conditionally read extra 4-byte TableBase for V1; version-aware SectionDirectoryOffset - Mono webcil-loader.c: accept both V0 and V1 headers, use correct header size for section offset calculation The WebcilConverter defaults to V0, which is what non-R2R builds use. The R2R/crossgen2 path (WasmObjectWriter + WebcilEncoder) produces V1 independently. Both CoreCLR and Mono decoders now handle V0 and V1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure |
pavelsavara
reviewed
Apr 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes browser-wasm test breakage caused by the Webcil header version bump (v0 → v1) by making the managed Webcil converter/reader and Mono loader accept and correctly process both v0 (28-byte) and v1 (32-byte) headers.
Changes:
- Add
TableBaseto the managedWebcilHeaderlayout to support v1’s 32-byte header. - Make the managed Webcil converter and reader version-aware (read/write correct header sizes; validate version; adjust section directory offset).
- Update Mono’s
webcil-loader.cto accept both v0 and v1 and compute offsets using the correct header size.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/WasmAppBuilder/WebcilConverter.cs | Threads a webcilVersion parameter through the MSBuild task wrapper to control header version written. |
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilReader.cs | Reads v0 header first, conditionally reads v1 TableBase, and adjusts section directory offset based on version. |
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs | Adds version parameterization and writes v0/v1 headers with bounds checking when serializing. |
| src/mono/mono/metadata/webcil-loader.c | Accepts both header versions with appropriate bounds checks and offset calculation. |
| src/coreclr/tools/Common/Wasm/Webcil.cs | Extends WebcilHeader with TableBase to represent the v1 header layout. |
davidwrighton
approved these changes
Apr 9, 2026
Member
Author
|
/ba-g the build failures are infra issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #126388 bumped the shared webcil version from 0 to 1, we need to update the rest of webcil ecosystem
Changes
TableBasefield to managedWebcilHeaderstruct (32 bytes for V1)webcilVersionparameter. Add version validation and WriteStructure bounds checks.SectionDirectoryOffset.The WebcilConverter defaults to V0, which is what non-R2R builds use. The R2R/crossgen2 path (WasmObjectWriter + WebcilEncoder) produces V1 independently. Both CoreCLR and Mono decoders now handle V0 and V1.
Testing
Supersedes #126698