[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

[browser] CoreCLR in-tree relink - #126946

Merged
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed
Apr 17, 2026
Merged

[browser] CoreCLR in-tree relink#126946
maraf merged 4 commits into
mainfrom
maraf/WasmCoreCLRNativeBuild-squashed

Conversation

@maraf

@marafmaraf commented Apr 15, 2026

Copy link
Copy Markdown
Member

Clean PR for original #125607

Summary

Implements the WASM native re-link pipeline for CoreCLR browser-wasm, replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a full Emscripten-based native build. This allows CoreCLR WASM apps to include custom native code via NativeFileReference items by re-linking dotnet.native.wasm from the CoreCLR static libraries shipped in the runtime pack.

Changes

src/mono/browser/build/BrowserWasmApp.CoreCLR.targets (+612 lines)

The core of this PR. Replaces the two stub targets with a complete native re-link pipeline:

  • Properties: Sets IsBrowserWasmProject, TargetsBrowser, forces WasmEnableExceptionHandling=true and WasmEnableSIMD=true (CoreCLR requires both), configures emcc as the compiler.

  • Entry points: WasmBuildApp (after Build) and WasmTriggerPublishApp (after Publish) with nested-publish support matching the Mono pattern.

  • Orchestrator: _CoreCLRWasmBuildAppCore chains the pipeline stages:

    1. _CoreCLRWasmInitialize — validates prerequisites, resolves runtime pack paths, creates intermediate directories.
    2. _CoreCLRSetupEmscripten — locates the Emscripten SDK (workload or EMSDK_PATH), sets environment variables for emcc.
    3. _CoreCLRPrepareForNativeBuild — resolves optimization flags, collects NativeFileReference items, builds compile flags (always includes -fwasm-exceptions -msimd128).
    4. _CoreCLRGenerateManagedToNative — runs ManagedToNativeGenerator to produce P/Invoke and interp-to-native tables from managed assemblies.
    5. _CoreCLRWriteCompileRsp — generates a coreclr_compat.h header with type/macro stubs (MethodDesc, PCODE, LOG, PORTABILITY_ASSERT, etc.) so ManagedToNativeGenerator output compiles outside the full CoreCLR build context. Writes the compile response file.
    6. _CoreCLRCompileNativeSources — invokes EmccCompile on user sources and generated tables.
    7. _CoreCLRWriteLinkRsp — builds linker arguments mirroring browserhost/CMakeLists.txt: CoreCLR static libraries (libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc.), JS libraries, ES6 module settings, memory configuration, exported functions/runtime methods.
    8. _CoreCLRLinkNative — invokes emcc with the link response file, producing dotnet.native.js, dotnet.native.wasm, and symbol maps.
    9. _CoreCLRCompleteNativeBuild — replaces pre-built runtime pack native assets with the re-linked versions.
    10. _CoreCLREmitAssembliesFinal — emits the final managed assembly list with satellite assembly handling.
  • Validates that users cannot disable EH or SIMD (errors out with a clear message).

  • Supports incremental builds via Inputs/Outputs on the link target.

  • Supports Debug/Release optimization flags (-O0/-O1/-O2).

  • Respects InvariantGlobalization and InvariantTimezone to skip ICU/timezone libraries.

eng/native.wasm.targets (+5/-1)

Adds Condition="'$(IsBrowserWasmProject)' != 'true'" to the ICU and timezone NuGet PackageReference items. During app-level relink the runtime pack already contains the pre-built native files; pulling in these packages at app build time would inject their contentFiles (timezone data files, READMEs) into the app's Content items, causing VFS / StaticWebAssets validation failures.

src/native/corehost/corehost.proj (+2)

Adds libSystem.Native.Browser.extpost.js to the list of files copied into the runtime pack's native directory. This JS file is required by the emcc linker during per-app native relinking (it's referenced as --extern-post-js in the link arguments).

src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs (+60)

Adds EnsureXHarnessAvailable() — a thread-safe helper that runs dotnet tool restore once per test process when XHARNESS_CLI_PATH is not set (local dev scenario). Prevents test failures caused by missing xharness CLI when running browser tests locally.

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs (+39/-28)

  • Extracts the CoreCLR-specific project property injection (version overrides, UseMonoRuntime=false, UsingBrowserRuntimeWorkload=false, KnownFrameworkReference/KnownWebAssemblySdkPack updates) into a reusable AddCoreClrProjectProperties() method.
  • Calls this method from both CreateWasmTemplateProject and CopyTestAsset, fixing a gap where template-created projects were missing the CoreCLR properties.
  • Calls EnsureXHarnessAvailable() before browser test runs.

Architecture

The pipeline mirrors the existing Mono WASM native build but is adapted for CoreCLR's different static library set and requirements:

App Build/Publish
→ WasmBuildApp / WasmTriggerPublishApp
→ _CoreCLRWasmBuildAppCore
→ Initialize (validate runtime pack)
→ Setup Emscripten (SDK paths, env vars)
→ Prepare (flags, NativeFileReference)
→ ManagedToNativeGenerator (P/Invoke tables)
→ Write compile RSP + compat header
→ EmccCompile (user sources + generated tables)
→ Write link RSP (mirrors CMakeLists.txt)
→ emcc link → dotnet.native.{js,wasm}
→ Replace runtime pack assets with re-linked output

Key differences from Mono WASM native build

  • EH & SIMD always on: CoreCLR WASM requires -fwasm-exceptions and -msimd128; user cannot disable them.
  • Different static libraries: Links libBrowserHost.a, libcoreclr_static.a, libcoreclrpal.a, etc. instead of libmonosgen-2.0.a.
  • Compat header: Generates coreclr_compat.h with type stubs so ManagedToNativeGenerator output (which references CoreCLR internals like MethodDesc, PCODE) compiles in the app build context without the full CoreCLR source tree.
  • Link flags: Mirror src/native/corehost/browserhost/CMakeLists.txt rather than the Mono wasm build.

Contributes to #123670
Contributes to #126100

Implements the WASM native re-link pipeline for CoreCLR browser-wasm,
replacing the stub WasmBuildApp / WasmTriggerPublishApp targets with a
full Emscripten-based native build.
Contributes to #123670
Contributes to #126100
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maraf
marafforce-pushed the maraf/WasmCoreCLRNativeBuild-squashed branch from d2627a4 to d7a9bc5CompareApril 15, 2026 11:34

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

Pull request overview

Implements an in-tree CoreCLR browser-wasm native re-link pipeline (emcc-based) so apps can re-link dotnet.native.wasm against CoreCLR static libs and include custom native code via NativeFileReference.

Changes:

  • Replaces stub CoreCLR WASM app targets with a full native compile/link pipeline driven by emcc response files.
  • Adjusts build/pack targets to support relink inputs (native assets + JS extern-post-js) and avoid ICU/timezone NuGet content pollution during app-level relink.
  • Updates WASM build tests to better support CoreCLR template projects and ensure xharness availability for local runs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/mono/browser/build/BrowserWasmApp.CoreCLR.targetsAdds the CoreCLR browser-wasm native relink MSBuild pipeline (initialize → generate → compile → link → register assets).
eng/native.wasm.targetsSkips ICU/timezone package refs for app-level relink and adjusts multithreading CMake arg logic.
src/native/corehost/corehost.projAdds runtime-pack copy of libSystem.Native.Browser.extpost.js and new host build CMake arg wiring.
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.csAdds a one-time tool-restore helper to ensure xharness is present locally.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.csRefactors CoreCLR-specific template property injection; ensures xharness availability; improves Blazor run readiness.
src/mono/browser/build/WasmApp.InTree.propsImports shared WASM props for CoreCLR and sets CoreCLR defaults (incl. WasmBuildNative).
src/mono/sample/wasm/Directory.Build.propsEnsures RuntimeFlavor is set early for in-tree sample builds (nested publish correctness).
Comments suppressed due to low confidence (3)

src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs:236

  • BootConfigFileName is part of MSBuildOptions and is used by tests (e.g., ModuleConfigTests.OverrideBootConfigName), but the MSBuild invocation no longer adds -p:WasmBootConfigFileName=... when this option is set. This makes the option ineffective and will likely break those tests. Reintroduce passing the property (while still omitting the implicit default when null).

buildOptions.ExtraBuildEnvironmentVariables["TreatPreviousAsCurrent"] = "false";
(CommandResult res, string logFilePath) = BuildProjectWithoutAssert(configuration, info.ProjectName, buildOptions);

src/native/corehost/corehost.proj:92

  • $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) is interpreted by MSBuild as a property name containing dots (not a string method call), so this will likely expand to empty and produce -DCLR_CMAKE_BUILD_HOST_TESTS= / -D...PRODUCT=. Use an MSBuild property function instead (e.g., $([System.String]::Copy('$(BuildNativeHostTests)').ToUpperInvariant())) or pass the lowercase value if CMake accepts it.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

src/native/corehost/corehost.proj:169

  • Same issue as above: $(BuildNativeHostTests.ToUpper()) / $(BuildNativeHostProduct.ToUpper()) will not call ToUpper() in MSBuild and likely expands to empty. Switch to an MSBuild property function (or another explicit transformation) so the CMake definitions receive TRUE/FALSE as intended.
 <BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_TESTS=$(BuildNativeHostTests.ToUpper())"</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DCLR_CMAKE_BUILD_HOST_PRODUCT=$(BuildNativeHostProduct.ToUpper())"</BuildArgs>

Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@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.

@marafmaraf added the os-browser Browser variant of arch-wasm label Apr 16, 2026
@marafmaraf added this to the 11.0.0 milestone Apr 16, 2026
CopilotAI review requested due to automatic review settings April 16, 2026 10:19

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment threadsrc/native/corehost/corehost.proj
Comment threadsrc/mono/browser/build/BrowserWasmApp.CoreCLR.targets
@github-actions

This comment was marked as resolved.

…eparators
$(WasmDirSep) is never defined anywhere in the codebase, causing the
fallback glob for System.Runtime.dll to produce an invalid path like
'libnet*System.Runtime.dll' instead of 'lib/net*/System.Runtime.dll'.
Use backslash separators matching the Mono equivalent in
WasmApp.Common.targets (MSBuild normalizes to the platform separator).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marafGitHub Codespaces

Copy link
Copy Markdown
MemberAuthor

/ba-g Failures are not related to this PR. All failing jobs match pre-existing known issues affecting many PRs across the repo.

JobKnown Issue
windows-x86 Release Libraries_NET481#127007 — "shared framework must be built" error (29 hits in 24h)
browser-wasm windows Release LibraryTests_Smoke_AOT#126997 — "Could not resolve type with token" in Mono AOT (43 hits in 7 days)
browser-wasm linux Release LibraryTests_Smoke_AOT#126997 — same as above
coreclr Pri0 Runtime Tests Run browser wasm checked#126714 — "Could not load System.Private.CoreLib.dll" on CLR wasm lanes
ios-arm64 Release AllSubsets_Mono_Smoke#126882 — Mono IL trimmer misidentifies platform on iOS
linux-x64 Debug Mono_Interpreter_LibrariesTests#126636CanReadArrayOfAnySize timeout on Mono interpreter (24 hits in 7 days)
Libraries Test Run checked coreclr linux x64 ReleasePre-existing infrastructure issue; no PR files touch coreclr linux libraries
maccatalyst-arm64 (cancelled)Dependency-cancelled due to upstream failure
browser-wasm windows WasmBuildTests (cancelled)Dependency-cancelled (AzDO timeout)

Note

This comment was generated with the assistance of GitHub Copilot.

@maraf
maraf merged commit cbb1e13 into mainApr 17, 2026
168 of 178 checks passed
@maraf
maraf deleted the maraf/WasmCoreCLRNativeBuild-squashed branch April 17, 2026 09:44
@github-actionsgithub-actionsBot locked and limited conversation to collaborators May 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-Build-monoos-browserBrowser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@maraf@pavelsavara@radekdoulik@jkotas@lewing