Skip to content

Add dedicated NativeAOT WASM build integration for WASI - #135955

Open
MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-build-integration
Open

MichalStrehovsky wants to merge 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-build-integration

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Summary

Add a dedicated NativeAOT WASM linker backend, with initial WASI support.

Use WASI SDK Clang and llvm-ar, portable runtime archives, and the required native dependencies to produce .wasm components targeting wasm32-wasip2. Keep WASM off Unix/ELF linker, linker-script, and objcopy stripping paths. StripSymbols is ignored on WASM, retaining embedded debug information.

Default data dehydration and managed stack-trace metadata off for WASM: their relative-function-pointer formats do not fit WASM table-index function pointers. Explicitly reject those unsupported formats, shared libraries, multi-module compilation, and aggregate executables.

Architecture selection is separate from WASI toolchain configuration; this does not treat all WASM as WASI or add browser linking support. WASI_SDK_PATH selects the SDK.

Validation

On the combined local NativeAOT WASI bringup tree, including other unmerged enablement:

  • .\dotnet.cmd msbuild src\coreclr\nativeaot\BuildIntegration\BuildIntegration.proj /t:Build /p:Configuration=Checked /p:TargetOS=wasi /p:TargetArchitecture=wasm /nologo /v:minimal passed.
  • .\src\tests\build.cmd nativeaot checked test nativeaot\SmokeTests\AttributeTrimming\AttributeTrimming.csproj wasm wasi passed after forced regeneration/relinking; Wasmtime execution returned 100.
  • Verified embedded DWARF remains with StripSymbols=true, and SDK Clang selects the component linker without an explicit -fuse-ld.

This branch contains only this cherry-picked commit from main; it was not built independently. Unix hosts and browser targets were not built or run.

Note

This PR description was generated by GitHub Copilot.

Use WASI SDK clang/llvm-ar and portable runtime archives to produce
.wasm components. Keep WASM off Unix/ELF linker, linker-script, and
symbol-stripping paths; retain embedded debug information.

Default dehydration and managed stack traces off: their metadata formats
encode relative function pointers, incompatible with WASM table indices.
Keep WASI toolchain setup distinct from architecture selection and reject
unsupported target OSes, shared libraries, and multi-module compilation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a6f3a617-acae-4f4f-95d3-20b2a0bac43c
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@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.

This branch was successfully deployed

1 active deployment
copilot-pat-pool — 82192cde Deployed Oct 16, 2026 by MichalStrehovsky via conclusion #10560
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.

1 participant