Uh oh!
There was an error while loading. Please reload this page.
[browser][coreCLR] Loading WebCIL - 2nd attempt - #124904
Conversation
Tagging subscribers to this area: @agocke, @elinor-fung |
There was a problem hiding this comment.
Pull request overview
Enables CoreCLR-on-Browser/WASM to load assemblies packaged in the Webcil container format (i.e., .wasm-wrapped assemblies), aligning CoreCLR behavior with existing Mono Webcil support and removing prior build/test overrides that forced raw .dll usage.
Changes:
- Adds CoreCLR-side Webcil decoding and wires it into
PEImageLayoutvia format-dispatched forwarding to eitherPEDecoder(PE) orWebcilDecoder(Webcil). - Updates the Webcil tooling pipeline (converter/reader/wrapper + MSBuild tasks/targets) including 16-byte section alignment and property renames (
WebCil*→Webcil*). - Extends cDAC contracts/readers and WASM test infrastructure to understand and exercise Webcil images.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilWasmWrapper.cs | Improves wrapper error message for payload offset validation. |
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilReader.cs | Updates to PascalCase header fields and adds bounds checking in RVA translation. |
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.cs | Renames Webcil header fields to PascalCase for consistency. |
| src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs | Implements 16-byte section alignment, debug directory translation, and related validations. |
| src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs | Renames output item list to WebcilCandidates. |
| src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ComputeWasmPublishAssets.cs | Renames task property to IsWebcilEnabled and updates usage. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/PEImageLayout.cs | Adds Format field to contract + helper to detect Webcil format. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs | Adds Webcil-aware RVA-to-offset logic by reading Webcil section table from target memory. |
| src/mono/wasm/features.md | Documentation update: “WebCIL” → “Webcil”. |
| src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs | Removes CoreCLR Webcil exclusion; renames env var WasmEnableWebcil. |
| src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets | Renames MSBuild properties/items/parameters from WebCil → Webcil. |
| src/mono/cmake/options.cmake | Documentation string update for ENABLE_WEBCIL. |
| src/mono/cmake/config.h.in | Comment update for ENABLE_WEBCIL. |
| src/mono/browser/debugger/BrowserDebugProxy/DebugStore.cs | Documentation wording update for Webcil handling. |
| src/mono/browser/build/WasmApp.InTree.props | Removes CoreCLR WasmEnableWebcil=false override. |
| src/coreclr/vm/peimagelayout.inl | Adds decoder-dispatch forwarding methods; introduces format-agnostic header checks. |
| src/coreclr/vm/peimagelayout.h | Refactors PEImageLayout to composition with PEDecoder/WebcilDecoder and ImageFormat discriminator. |
| src/coreclr/vm/peimagelayout.cpp | Initializes Webcil decoder on detection; updates PEDecoder init/reset call sites; DAC enumeration dispatch. |
| src/coreclr/vm/peimage.inl | Adds PEImage::HasHeaders() helper. |
| src/coreclr/vm/peimage.h | Declares HasHeaders() in PEImage. |
| src/coreclr/vm/peimage.cpp | Uses HasHeaders() instead of HasNTHeaders() in metadata/debug-directory paths. |
| src/coreclr/vm/peassembly.cpp | Accepts IMAGE_FILE_MACHINE_UNKNOWN for IL-only validation; guards 32-bit header check. |
| src/coreclr/vm/eventtrace.cpp | Switches checks from NT headers to format-agnostic headers. |
| src/coreclr/vm/debugdebugger.cpp | Switches from PEDecoder* to PEImageLayout* and uses GetDirectoryEntryData. |
| src/coreclr/vm/datadescriptor/datadescriptor.inc | Adds Format field to PEImageLayout’s cDAC data descriptor. |
| src/coreclr/vm/ceeload.cpp | Updates IJW lookup to use PEImageLayout* (post-inheritance refactor). |
| src/coreclr/utilcode/webcildecoder.cpp | Adds CoreCLR Webcil decoding/validation implementation and DAC enumeration support. |
| src/coreclr/utilcode/CMakeLists.txt | Adds webcildecoder.cpp to utilcode build. |
| src/coreclr/inc/webcildecoder.h | Adds Webcil structures and WebcilDecoder API. |
| src/coreclr/inc/pedecoder.h | Makes PEImageLayout a friend and restricts PE-internal APIs to PEImageLayout usage. |
| src/coreclr/clrfeatures.cmake | Enables FEATURE_WEBCIL for browser builds. |
| src/coreclr/clrdefinitions.cmake | Adds FEATURE_WEBCIL compile definition when enabled. |
| src/coreclr/binder/assemblybindercommon.cpp | Treats IMAGE_FILE_MACHINE_UNKNOWN as processor-agnostic MSIL in binder logic. |
| eng/testing/tests.browser.targets | Removes CoreCLR WasmEnableWebcil=false override for browser tests. |
| docs/design/mono/webcil.md | Updates spec text for alignment and PascalCase field names + naming consistency. |
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilReader.cs:354
- New exceptions in
TranslateRVAusenameof(_stream)as the parameter name. Since_streamis a private field (not a parameter), this produces a less helpfulParamNamethannameof(stream)(constructor parameter) or omitting the param name entirely. Consider aligning with the earlier constructor exceptions which usenameof(stream).
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.
Uh oh!
There was an error while loading. Please reload this page.
0ad7f18 to
883ce1cCompareThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
src/coreclr/utilcode/CMakeLists.txt:1
webcildecoder.cppis added unconditionally toUTILCODE_COMMON_SOURCES. WhenFEATURE_WEBCILis off this compiles an effectively empty translation unit, which is small but avoidable build work. Consider conditionally appendingwebcildecoder.cpponly whenFEATURE_WEBCILis enabled (orCLR_CMAKE_TARGET_BROWSER), to keep non-browser builds slightly leaner.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
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.
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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
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.
max-charlamb
commented
Mar 13, 2026
Looks good to me from a cDAC perspective. Thanks for keeping the cDAC up to date 👍 |
pavelsavara
commented
Mar 13, 2026
/ba-g unrelated CI failures |
Uh oh!
There was an error while loading. Please reload this page.
Enable Webcil loading in CoreCLR for Browser/WASM
Summary
Adds native Webcil container format support to the CoreCLR runtime, enabling CoreCLR-on-WASM to load
.wasm-wrapped assemblies directly — previously only supported by the Mono runtime. Removes theWasmEnableWebcil=falseoverride that was forcing CoreCLR browser builds to use raw.dllfiles.Changes
CoreCLR Webcil decoder (
src/coreclr/)WebcilDecoderclass (webcildecoder.h,webcildecoder.cpp) — standalone reader for the Webcil container format with full RVA/offset translation, COR header resolution, metadata access, section validation, IL method checking, debug directory support, and DAC enumeration.FEATURE_WEBCILcmake gate enabled forCLR_CMAKE_TARGET_BROWSER(clrfeatures.cmake,clrdefinitions.cmake).PEImageLayoutcomposition refactor (src/coreclr/vm/)PEImageLayoutno longer inherits fromPEDecoder; instead holdsm_peDecoder(and conditionallym_webcilDecoder) as members with anImageFormatdiscriminator (FORMAT_PE/FORMAT_WEBCIL).peimagelayout.inldispatch to the active decoder viaDECODER_DISPATCH/DECODER_CHECK/PE_OR_WEBCILmacros.PEDecoderpublic API split: methods needed byPEImageLayoutforwarding stay public; PE-internal helpers (GetHeaders,GetDirectoryEntry,CheckDirectoryEntry, relocation/TLS/strong-name internals, etc.) moved to a private section accessible only viafriend class PEImageLayout.FlatImageLayoutconstructor detects Webcil magic and initializes both decoders (Webcil for format operations, PE decoder for base/size/flags used by cDAC).HasHeaders()abstraction onPEImageLayoutandPEImage— returnsHasWebcilHeaders()orHasNTHeaders()depending on format. Callers inpeassembly.cpp,peimage.cpp,eventtrace.cppupdated fromHasNTHeaders()toHasHeaders().debugdebugger.cpp: switched fromPEDecoder*toPEImageLayout*and uses format-agnosticGetDirectoryEntryDatainstead of rawGetDirectoryEntry+GetDirectoryData.ceeload.cpp: samePEDecoder*→PEImageLayout*fix for IJW host lookup.peassembly.cpp: acceptIMAGE_FILE_MACHINE_UNKNOWN(Webcil machine type) for IL-only validation; guard 32-bit NT header check withHasNTHeaders().assemblybindercommon.cpp: treatIMAGE_FILE_MACHINE_UNKNOWNas processor-agnostic MSIL.cDAC diagnostics (
src/native/managed/cdac/)PEImageLayoutdata descriptor gainsFormatfield (datadescriptor.inc,PEImageLayout.cs).Loader_1.cs: Webcil-awareRvaToOffsetpath that reads the Webcil section table directly from the target memory whenIsWebcilFormatis set.Build/infrastructure
WasmEnableWebcil=falsefrom CoreCLR browser build properties (WasmApp.InTree.props,tests.browser.targets).WebCilCandidates→WebcilCandidates,IsWebCilEnabled→IsWebcilEnabled,_WasmBuildWebCilPath→_WasmBuildWebcilPathand related properties.BuildEnvironment.csremoves CoreCLR Webcil exclusion; env varWasmEnableWebCil→WasmEnableWebcil.