Skip to content

Build wasm JIT and crossgen2 R2R of System.Private.CoreLib for browser target#127935

Open
davidwrighton wants to merge 1 commit intodotnet:mainfrom
davidwrighton:Build_CrossGen_andR2R_SPC
Open

Build wasm JIT and crossgen2 R2R of System.Private.CoreLib for browser target#127935
davidwrighton wants to merge 1 commit intodotnet:mainfrom
davidwrighton:Build_CrossGen_andR2R_SPC

Conversation

@davidwrighton
Copy link
Copy Markdown
Member

Note

This PR was created with assistance from GitHub Copilot.

Enable build.cmd clr+libs -os browser to:

  1. Build clrjit_universal_wasm_x64 (the wasm-targeting JIT for the host platform)
  2. Build crossgen2 that can use the wasm JIT
  3. Run crossgen2 on System.Private.CoreLib to produce a .wasm R2R output

Changes

  • eng/Subsets.props: Remove wasm exclusion from _BuildAnyCrossArch; use ClrWasmJitSubset for wasm targets
  • src/coreclr/CMakeLists.txt: Early-return for wasm cross-component builds (only configure JIT + dependencies)
  • src/coreclr/jit/CMakeLists.txt: Create clrjit_universal_wasm_* when target=wasm
  • src/coreclr/gcinfo/CMakeLists.txt: Create gcinfo_universal_wasm library
  • src/coreclr/crossgen-corelib.proj: Enable crossgen2 for browser with --obj-format:wasm and --codegenopt:JitWasmNyiToR2RUnsupported=1; output as System.Private.CoreLib.NotReadyYet.wasm
  • eng/native/configureplatform.cmake: Guard emscripten link/compile options from cross-component builds
  • src/coreclr/jit/compiler.cpp & codegenwasm.cpp: Add missing #ifdef PROFILING_SUPPORTED guards
  • src/coreclr/utilcode/CMakeLists.txt: Guard natvis for wasm target
  • src/coreclr/tools/aot/crossgen2/crossgen2.props: Allow jitinterface pickup for wasm when CrossHostArch is set

…r target

Enable 'build.cmd clr+libs -os browser' to:
1. Build clrjit_universal_wasm_x64 (the wasm-targeting JIT for the host platform)
2. Build crossgen2 that can use the wasm JIT
3. Run crossgen2 on System.Private.CoreLib to produce a .wasm R2R output

Key changes:
- eng/Subsets.props: Remove wasm exclusion from cross-arch build; use ClrWasmJitSubset
- src/coreclr/CMakeLists.txt: Early-return for wasm cross-component (only JIT+deps)
- src/coreclr/jit/CMakeLists.txt: Create clrjit_universal_wasm_* target
- src/coreclr/gcinfo/CMakeLists.txt: Create gcinfo_universal_wasm library
- src/coreclr/crossgen-corelib.proj: Enable crossgen2 for browser with wasm format
- eng/native/configureplatform.cmake: Guard emscripten flags from cross-component builds
- Fix missing PROFILING_SUPPORTED guards in JIT wasm codegen

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 23:38
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 7, 2026
@davidwrighton davidwrighton requested a review from agocke May 7, 2026 23:38
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CoreCLR build and crossgen plumbing to enable a browser/wasm-targeting “cross-components” build that produces a wasm-targeting standalone JIT (clrjit_universal_wasm_*), builds a crossgen2 that can consume that JIT, and runs crossgen2 over System.Private.CoreLib to emit a wasm object/container output.

Changes:

  • Enable building the wasm-targeting standalone JIT and its gcinfo dependency under wasm targeting.
  • Adjust subset/build logic so wasm targets build only the needed cross-component pieces (wasm JIT subset) rather than all cross-arch JITs.
  • Enable browser corelib crossgen2 invocation with --obj-format:wasm and a wasm-specific codegen option; tighten a few wasm/cross-component guards (profiling, natvis, emscripten flags).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
eng/Subsets.props Enables cross-component builds for wasm targets and selects ClrWasmJitSubset instead of ClrAllJitsSubset when targeting wasm.
eng/native/configureplatform.cmake Avoids applying emscripten-specific compile/link flags to cross-component builds.
src/coreclr/CMakeLists.txt Adds an early-return path for wasm cross-components builds and ensures jitinterface is configured for browser when cross-component building.
src/coreclr/crossgen-corelib.proj Enables browser crossgen2 with wasm obj-format and a wasm-specific codegen opt; sets wasm output path.
src/coreclr/gcinfo/CMakeLists.txt Adds gcinfo_universal_wasm library creation for wasm-targeting builds.
src/coreclr/jit/CMakeLists.txt Creates clrjit_universal_wasm_${ARCH_HOST_NAME} when targeting wasm.
src/coreclr/jit/compiler.cpp Guards verbose printing of profiler-hook state behind PROFILING_SUPPORTED.
src/coreclr/jit/codegenwasm.cpp Guards genProfilingLeaveCallback definition behind PROFILING_SUPPORTED.
src/coreclr/tools/aot/crossgen2/crossgen2.props Allows shipping/picking up jitinterface content for wasm scenarios when CrossHostArch is set.
src/coreclr/utilcode/CMakeLists.txt Skips linking natvis into utilcode_dac when targeting wasm (where that target isn’t built).

Comment on lines +187 to +196
# For wasm cross-component builds, only the JIT and jitinterface are needed.
# Skip subsystems (GC, VM, debug, etc.) that don't support wasm as a target.
if(CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_TARGET_ARCH_WASM)
include_directories("inc")
include_directories("minipal")
add_subdirectory(utilcode)
add_subdirectory(gcinfo)
add_subdirectory(jit)
return()
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants