Skip to content

Fix NativeAOT WASM test native library linkage - #136786

Merged
MichalStrehovsky merged 5 commits into
dotnet:mainfrom
MichalStrehovsky:fix-nativeaot-wasm-test-linking
Nov 10, 2026
Merged

MichalStrehovsky merged 5 commits into
dotnet:mainfrom
MichalStrehovsky:fix-nativeaot-wasm-test-linking

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Exclude NativeAOT from corerun imports and link native test archives with direct P/Invokes. Enable the PInvoke native library on WASI, correct native return signatures, and skip unsupported delegate callback thunk tests on WASM.

Co-authored-by: Copilot [email protected]

Exclude NativeAOT from corerun imports and link native test archives with direct P/Invokes. Enable the PInvoke native library on WASI, correct native return signatures, and skip unsupported delegate callback thunk tests on WASM.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 588bbf5d-e3b3-4e23-869e-bbec249dfb32
Remove the NativeAOT WASM merged-wrapper archive copying change while retaining standalone native library linkage.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 588bbf5d-e3b3-4e23-869e-bbec249dfb32
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The native-library wiring omits a required archive and loses symbol isolation between colliding exports, causing unresolved helpers and potentially incorrect interop bindings.

3 open issues
What changed in this PR

This PR updates the runtime test infrastructure to link native test libraries into NativeAOT WebAssembly executables and enables the P/Invoke smoke test’s native library on WASI.

Changes:

  • Excludes NativeAOT from corerun-specific imports and adds static archives with direct P/Invoke bindings.
  • Enables the native P/Invoke library on WASI and uses target-platform Windows linkage.
  • Corrects two native return signatures and adds WASM guards around delegate callback tests.
File Description
src/​tests/​nativeaot/​SmokeTests/​PInvoke/​PInvoke.cs Corrects return types and skips delegate callback scenarios on WASM.
src/​tests/​nativeaot/​SmokeTests/​PInvoke/​CMakeLists.txt Allows WASI builds and selects Windows libraries by target platform.
src/​tests/​Directory.Build.targets Separates NativeAOT from corerun setup and adds native archive linkage.

Review effort: Balanced

Comment thread src/tests/Directory.Build.targets Resolved
Comment thread src/tests/Directory.Build.targets Resolved
Reuse native test archive selection between WasmCorerun and NativeAOT, including the common platform helper archive. Preserve supported delegate function-pointer coverage on WASM.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 275b1487-9388-4eff-842a-414088e1ba33
@jkotas
jkotas requested a review from radekdoulik November 2, 2026 18:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The shared MSBuild/CMake linkage changes require NativeAOT WASI PInvoke smoke execution and CoreCLR WASM native-asset regression validation beyond the source-level review performed.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@jtschuster could you have a look please? This is pulling out some functionality from CLRTest.WasmCorerun.targets (that among other things builds a test-specific corerun that includes native test assets). Then uses the pulled out functionality to link native test assets into the native AOT executable same as corerun does. Also fixes some p/invoke signature mismatches and extracts tests that depend on Marshal.GetFunctionPointerForDelegate (that would require creating new native function pointers at runtime).

@MichalStrehovsky
MichalStrehovsky merged commit 6a8c4ed into dotnet:main Nov 10, 2026
80 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix-nativeaot-wasm-test-linking branch November 10, 2026 00:37
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-NativeAOT-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants