[browser][coreCLR] no COM, no swift#125083
Open
pavelsavara wants to merge 6 commits intodotnet:mainfrom
Open
Conversation
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce trimmed size for browser-WASM CoreCLR builds by removing/gating roots and native support code for features that aren’t supported in the browser (COM/interop-related pieces, DynamicInterfaceCastable, Swift interop, and intrinsics metadata rooting).
Changes:
- Filters reverse P/Invoke stub generation for types marked
[UnsupportedOSPlatform("browser")]and annotatesComActivatoraccordingly. - Gates ILLink rooting for
ComponentActivator.GetFunctionPointerbehind the existing native-hosting feature switch. - Adds
TARGET_WASMguards to exclude DynamicInterfaceCastable native support on WASM and trims related ILLink roots / metadata retention paths.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/WasmAppBuilder/generate-coreclr-helpers.cmd | Updates helper generation script used for CoreCLR WASM callhelper regeneration. |
| src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs | Skips generating reverse P/Invoke callback stubs for types unsupported on browser. |
| src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs | Removes CompExactlyDependsOnAttribute metadata for browser/WASI builds to improve trimming. |
| src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml | Gates ComponentActivator.GetFunctionPointer rooting behind the native-hosting feature switch. |
| src/coreclr/vm/wasm/callhelpers-reverse.cpp | Regenerated reverse thunk table reflecting removed callbacks. |
| src/coreclr/vm/wasm/callhelpers-pinvoke.cpp | Regenerated P/Invoke table reflecting upstream removals. |
| src/coreclr/vm/virtualcallstub.cpp | Removes DynamicInterfaceCastable resolver path from WASM builds. |
| src/coreclr/vm/rexcep.h | Attempts to exclude interop exception types from WASM ILLink descriptor generation. |
| src/coreclr/vm/methodtable.cpp | Removes IDynamicInterfaceCastable special method resolution on WASM. |
| src/coreclr/vm/jithelpers.cpp | Removes IDynamicInterfaceCastable cast path on WASM. |
| src/coreclr/vm/dynamicinterfacecastable.h | Wraps DynamicInterfaceCastable API surface out of WASM builds. |
| src/coreclr/vm/dynamicinterfacecastable.cpp | Wraps DynamicInterfaceCastable implementation out of WASM builds. |
| src/coreclr/vm/corelib.h | Attempts to exclude Swift interop and ComVariant from WASM ILLink descriptor generation; removes DynamicInterfaceCastableHelpers from WASM. |
| src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs | Marks ComActivator as unsupported on browser to suppress reverse stub generation. |
jkotas
reviewed
Mar 3, 2026
c066985 to
77b2da7
Compare
This was referenced Mar 3, 2026
77b2da7 to
cb5be74
Compare
This was referenced Mar 13, 2026
1 task
radekdoulik
reviewed
Mar 18, 2026
.../System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs
Outdated
Show resolved
Hide resolved
radekdoulik
reviewed
Mar 18, 2026
radekdoulik
approved these changes
Mar 18, 2026
Member
radekdoulik
left a comment
There was a problem hiding this comment.
Beside the 2 comments it LGTM, thank you!
jkotas
reviewed
Mar 18, 2026
jkotas
reviewed
Mar 18, 2026
jkotas
reviewed
Mar 18, 2026
jkotas
reviewed
Mar 18, 2026
src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml
Outdated
Show resolved
Hide resolved
Member
Do you have any numbers for the size improvement? |
- fallback to kException when not FEATURE_COMINTEROP instead of kSEHException and kCOMException - revert of CompExactlyDependsOnAttribute, GetFunctionPointer - regenerated helpers
jkotas
reviewed
Mar 20, 2026
jkotas
reviewed
Mar 20, 2026
jkotas
reviewed
Mar 20, 2026
This was referenced Mar 20, 2026
Open
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.
Trim dead interop/COM code from browser-WASM CoreCLR builds
Summary
This PR reduces the browser-WASM CoreCLR native binary size by excluding COM interop, SEH exception, and Swift interop code that cannot run on the browser platform.
Changes
1. Guard COM/Interop exception types with FEATURE_COMINTEROP (
excep.h)
2. Guard SEHException handling block with TARGET_WASM (clrex.cpp)
#ifndef TARGET_WASM. WASM has no hardware exception (signal) support, so SEHException objects are never produced on that platform.3. Fix MapWin32FaultToCOMPlusException default case (�xcep.cpp)
4. Guard ComVariant references with FEATURE_COMINTEROP
5. Restrict Swift interop types to Apple platforms (corelib.h)
Guard SwiftSelf, SwiftSelf, SwiftError, and SwiftIndirectResult with #if defined(TARGET_APPLE). Swift interop is not supported on WASM or other non-Apple platforms.
6. Add [UnsupportedOSPlatform("browser")] to ComActivator
File: ComActivator.PlatformNotSupported.cs
Annotate ComActivator with [UnsupportedOSPlatform("browser")] so its [UnmanagedCallersOnly] methods are excluded from generated reverse P/Invoke stubs on browser builds.
7. Filter [UnsupportedOSPlatform("browser")] types from reverse P/Invoke stubs
File: PInvokeCollector.cs
Add IsUnsupportedOnBrowser() helper to DoesMethodHaveCallbacks() — skips generating reverse P/Invoke callback stubs for methods on types annotated with [UnsupportedOSPlatform("browser")].
8. Regenerated callhelpers files
Files: callhelpers-pinvoke.cpp, callhelpers-reverse.cpp, callhelpers-interp-to-managed.cpp
Regenerated to reflect the ComActivator exclusion and upstream changes.
Testing
Build verified with
.\build.cmd -bl -os browser -subset clr -c Release /p:RuntimeFlavor=CoreCLR.