Skip to content

[wasm] Package CoreCLR native symbol map - #134010

Merged
lewing merged 2 commits into
mainfrom
lewing-native-wasm-profiler-symbols
Sep 17, 2026
Merged

lewing merged 2 commits into
mainfrom
lewing-native-wasm-profiler-symbols

Conversation

@lewing

@lewing lewing commented Sep 15, 2026

Copy link
Copy Markdown
Member

CoreCLR browser builds already generate Emscripten's dotnet.native.js.symbols, but the browser runtime .nupkg did not contain it. This adds the existing file to the CoreCLR runtime-pack harvest, matching Mono, so WasmEmitSymbolMap=true can publish native symbols without forcing an application relink.

The Emscripten index:name payload remains unchanged. The boot resource model now retains the symbols file's SHA-256 alongside the existing final-wasm SHA-256, so fingerprinted published files can be discovered and verified as an exact pair.

Validation includes an independent WebAssembly import/function/code/export parser and Emscripten-map parser. It verifies absolute module function indices include imports, checks runtime/interpreter/libc/exported/compiler-generated anchors, and rejects shifted indices, stale wasm identity, and mutated symbol-map bytes.

Current Release artifacts:

Artifact Size SHA-256
dotnet.native.wasm 4,698,251 bytes 4abe2a6ca7e5cc5f8bc674d0a111e7e3e3ed1f78cc2c28a0387d74b8ce22fd04
dotnet.native.js.symbols 655,281 bytes 19b6b201a88b019db6b822a2baf3e5a8022f54ef4e385633b931255e80b1ef4b

The runtime .nupkg grew from 71,838,978 to 71,984,589 bytes (+145,611 bytes, 0.20%). Application publish remains opt-in through WasmEmitSymbolMap.

Live Chrome/CDP cross-check:

  • V8 stopped at absolute function index 9614, resolved by the map as BrowserHost_ExecuteAssembly.
  • V8 then stopped at stripped $func2243; the map resolves index 2243 to InterpExecMethod(InterpreterFrame*, InterpMethodContextFrame*, InterpThreadContext*, ExceptionClauseArgs*).
  • Its stripped caller $func2276 resolves to ExecuteInterpretedMethod.

R2R transition thunks are functions in separately loaded Webcil modules and remain covered by their module-local name sections from #132906; they are intentionally not folded into this native-host map.

Validation run:

  • PATH=/opt/homebrew/bin:$PATH ./build.sh -os browser -c Release -subset clr+libs
  • Wasm.Build.Tests.ModuleConfigTests.RuntimePackSymbolMapMatchesFinalWasm — 1 passed
  • Wasm.Build.Tests.ModuleConfigTests.RuntimePackSymbolMapRejectsIndexAndIdentityMismatches — 1 passed
  • Wasm.Build.Tests.ModuleConfigTests.SymbolMapFileEmitted — build and publish cases passed, including fingerprinted static assets
  • Wasm.Build.Tests.ModuleConfigTests.SymbolMapFileNotEmitted — build and publish opt-out cases passed

Resolves #134009

Note

This pull request was generated by GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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.

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

Comment thread src/mono/wasm/Wasm.Build.Tests/ModuleConfigTests.cs Outdated

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.

Copilot review overview

🟢 Approval recommended

The reviewed changes and validation coverage show no unresolved blocking issues.

Review tier: Lite
Findings: None

What changed in this PR

Adds CoreCLR’s WebAssembly native symbol map to runtime packs and preserves its integrity hash through publishing.

Changes:

  • Packages dotnet.native.js.symbols for CoreCLR.
  • Propagates symbol-map hashes through boot resources and type declarations.
  • Adds packaging, fingerprinting, and parser-based validation tests.
File Description
src/​tasks/​Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/​BootJsonData.cs Adds symbol asset hash data.
src/​tasks/​Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/​BootJsonBuilderHelper.cs Emits symbol-map hashes in boot resources.
src/​native/​libs/​Common/​JavaScript/​types/​public-api.ts Updates native asset types.
src/​native/​libs/​Common/​JavaScript/​loader/​dotnet.d.ts Updates native declarations.
src/​mono/​wasm/​Wasm.Build.Tests/​ModuleConfigTests.cs Tests emission, fingerprinting, and integrity pairing.
src/​mono/​wasm/​Wasm.Build.Tests/​CoreCLRWasmNativeDefaultsTests.cs Validates WebAssembly and symbol-map consistency.
src/​mono/​browser/​runtime/​types/​index.ts Updates Mono asset types.
src/​mono/​browser/​runtime/​dotnet.d.ts Updates Mono declarations.
eng/​liveBuilds.targets Harvests the CoreCLR native symbol map.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0e7a5257-2a84-497d-864c-aebcd675504c
Copilot AI review requested due to automatic review settings September 17, 2026 16:29
@lewing

lewing commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

@maraf @pavelsavara I think I have addressed the review

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.

Copilot review overview

🟢 Approval recommended

Validation covers packaging, publishing, fingerprinting, and symbol-map integrity with no unresolved blocking issues.

Review effort: Lite
Findings: None

@lewing
lewing enabled auto-merge (squash) September 17, 2026 17:32
@lewing
lewing merged commit 14cf8f9 into main Sep 17, 2026
160 of 163 checks passed
@lewing
lewing deleted the lewing-native-wasm-profiler-symbols branch September 17, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package CoreCLR browser WebAssembly native symbol map

4 participants