You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preserve .NET P/Invoke call-site semantics for CoreCLR WebAssembly ReadyToRun images without relying on runtime fallback to stripped IL.
Crossgen2 now distinguishes P/Invokes that can be emitted directly from those that require runtime resolution:
modules supplied through --directpinvoke, QCalls, and * static imports remain direct R2R P/Invokes;
WasmImportLinkageAttribute remains direct and resolves through the WebAssembly import table rather than the static native-module list;
ordinary imports not proven statically available are treated as requiring marshalling, so callers remain valid R2R methods and resolution occurs only when the P/Invoke is reached.
Browser and WASI app builds pass their supported module lists to Crossgen2. CoreLib and prebuilt browser framework R2R generation use the same canonical framework list as the portable call-helper generator. The canonical build configuration lives under eng/wasm and is packaged beside the browser runtime SDK target for out-of-tree builds. A shared WASM build task computes the effective module set for browser and WASI, including platform applicability, invariant globalization, supported native inputs, canonical module names, and deduplication.
The module list is written to an incremental-build manifest so adding or removing a native module invalidates the corresponding R2R images.
The earlier VM-level method-rejection implementation has been removed. This avoids a new R2R-to-IL fallback path and remains compatible with --strip-il-bodies.
Addresses the Runtime_58874 failure tracked by #133259 and the broader guarded-platform-probe behavior reported in #133614.
WASI CoreCLR runtime and runtime pack build: passed.
Browser-wasm R2R Interop/PInvoke/Unresolved/UnresolvedPInvokeTests passed with --strip-il-bodies and --directpinvoke:libSystem.Native.
WASI R2R Interop/PInvoke/Unresolved/UnresolvedPInvokeTests passed with the same stripped-IL configuration.
Packaged workload WBT for CoreCLR R2R + NativeFileReference passed, including native relinking, native-lib module classification, and the P/Invoke result.
The preserved pre-policy browser runtime fails the call-site timing assertion under --strip-il-bodies; the new policy passes it.
R2RDump confirms the image has READYTORUN_FLAG_StrippedILBodies, configured libSystem.Native calls retain PINVOKE_TARGET fixups, and unresolved callers do not embed those fixups.
CoreCLR browser sample publish with R2R and native relinking: passed; its generated P/Invoke manifest matches the call-helper module list.
Native test execution: passed.
No benchmark is applicable to permanently unavailable imports. Configured direct P/Invokes retain the existing direct PINVOKE_TARGET codegen and add no runtime branch.
Note
This pull request description and changes were prepared with GitHub Copilot assistance.
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.
These branches now determine which modules receive --directpinvoke for CoreCLR ReadyToRun, but the new ReadyToRun workload test covers only a custom NativeFileReference. The NativeLibrary path, invariant-globalization filtering, and Browser/WASI applicability are not exercised by an R2R test; the existing invariant test only validates the non-R2R native relink. Add focused R2R coverage for these cases so a regression cannot classify an unavailable module as direct.
[!NOTE] This review comment was generated with GitHub Copilot assistance.
The P/Invoke classification fix from dotnet#133773 allows guarded platform probes to remain R2R compiled. Remove the temporary TestUtilities interpreter exception and its documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
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.
Summary
Preserve .NET P/Invoke call-site semantics for CoreCLR WebAssembly ReadyToRun images without relying on runtime fallback to stripped IL.
Crossgen2 now distinguishes P/Invokes that can be emitted directly from those that require runtime resolution:
--directpinvoke, QCalls, and*static imports remain direct R2R P/Invokes;WasmImportLinkageAttributeremains direct and resolves through the WebAssembly import table rather than the static native-module list;Browser and WASI app builds pass their supported module lists to Crossgen2. CoreLib and prebuilt browser framework R2R generation use the same canonical framework list as the portable call-helper generator. The canonical build configuration lives under
eng/wasmand is packaged beside the browser runtime SDK target for out-of-tree builds. A shared WASM build task computes the effective module set for browser and WASI, including platform applicability, invariant globalization, supported native inputs, canonical module names, and deduplication.The module list is written to an incremental-build manifest so adding or removing a native module invalidates the corresponding R2R images.
The earlier VM-level method-rejection implementation has been removed. This avoids a new R2R-to-IL fallback path and remains compatible with
--strip-il-bodies.Addresses the
Runtime_58874failure tracked by #133259 and the broader guarded-platform-probe behavior reported in #133614.Validation
Interop/PInvoke/Unresolved/UnresolvedPInvokeTestspassed with--strip-il-bodiesand--directpinvoke:libSystem.Native.Interop/PInvoke/Unresolved/UnresolvedPInvokeTestspassed with the same stripped-IL configuration.NativeFileReferencepassed, including native relinking,native-libmodule classification, and the P/Invoke result.--strip-il-bodies; the new policy passes it.READYTORUN_FLAG_StrippedILBodies, configuredlibSystem.Nativecalls retainPINVOKE_TARGETfixups, and unresolved callers do not embed those fixups.No benchmark is applicable to permanently unavailable imports. Configured direct P/Invokes retain the existing direct
PINVOKE_TARGETcodegen and add no runtime branch.Note
This pull request description and changes were prepared with GitHub Copilot assistance.