Skip to content

Test harness and assorted changes for R2R testing in Wasm#128156

Merged
davidwrighton merged 5 commits into
dotnet:mainfrom
davidwrighton:WasmR2RTestsWithCrossgen2
May 14, 2026
Merged

Test harness and assorted changes for R2R testing in Wasm#128156
davidwrighton merged 5 commits into
dotnet:mainfrom
davidwrighton:WasmR2RTestsWithCrossgen2

Conversation

@davidwrighton
Copy link
Copy Markdown
Member

  • Add --help output for --obj-format switch to crossgen2.
  • Minor tweak to R2RTest, if anyone is still using that
  • Add support for the detail that R2R on wasm targets produces .wasm files instead of .dll files
  • When tests are built with RuntimeFlavor=coreclr, then they will default to setting RunWithNodeJS to true
  • Copy crossgen2 from a cross-build directory on Wasm
  • Enable bash and batch precommands when building wasm tests
    • Disable a few tests that had problematic precommands for testing

When this PR and PR #127935 are merged, it will be straightforward enough to run tests.

The process will be something like:

Commands to run tests, starting from a fresh build

; Build runtime+libs
./build.sh clr+libs -rc debug -c release -os browser
; Build TestRoot
./src/tests/build.sh skipmanaged browser
; Build test project from the test tree
./dotnet.sh /p:TargetArchitecture=wasm /p:TargetOS=browser /p:RuntimeFlavor=coreclr src/tests/GC/API/GCSettings/InducedGen0GC.csproj

export CORE_ROOT=/home/davidwr/git/runtime/artifacts/tests/coreclr/browser.wasm.Debug/Tests/Core_Root
export RunCrossGen2=1
/home/davidwr/git/runtime/artifacts/tests/coreclr/browser.wasm.Debug/GC/API/GCSettings/InducedGen0GC/InducedGen0GC.sh

davidwrighton and others added 4 commits May 13, 2026 11:16
Use .wasm file extension for WASM R2R output in test scripts

WASM R2R images should use .wasm extension instead of .dll. Update
CLRTest.CrossGen.targets to:
- Set output extension to .wasm for both composite and non-composite
  modes in bash and batch scripts when CrossGen2OutputFormat is 'wasm'
- Pass -f flag to crossgen2 in batch scripts (matching bash behavior)

Also set CrossGen2OutputFormat=wasm in Directory.Build.props for
browser target OS so all tests targeting wasm use the correct format.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 'browser' and 'wasi' shorthand commands to src/tests/build.sh,
  matching existing support in build.cmd
- Auto-set architecture to wasm when browser or wasi target is selected
  in both build.sh and build.cmd
- Fix crossgen2 binary not being copied to Core_Root for wasm builds
  by copying from the cross-targeting x64/crossgen2 directory when the
  crossgen2-published directory does not exist
- Make generated test scripts (.sh and .cmd) default RunWithNodeJS=1
  for CoreCLR browser builds, matching existing Helix CI behavior
- Mark readytorun tests as unsupported on wasm architecture

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

Move TakeLock/ReleaseLock for RunCrossGen2 outside the RunWithNodeJS
guard in the wasm pre-commands section of both CLRTest.Execute.Bash.targets
and CLRTest.Execute.Batch.targets. Previously, the crossgen2 lock was
inside the 'if not RunWithNodeJS' block, so when RunWithNodeJS defaulted
to 1 for CoreCLR builds, crossgen2 was never invoked. Only the wasm app
build (WasmTestRunner.proj) should be conditional on RunWithNodeJS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 test harness and supporting tooling to make ReadyToRun (R2R) / Crossgen2 testing work for WebAssembly targets, including handling wasm-specific output artifacts and improving the wasm test execution flow (browser/wasi) in the src/tests infrastructure and related tools.

Changes:

  • Add/propagate wasm-specific Crossgen2 output handling (produce .wasm outputs, plumb -f/--obj-format, and default wasm execution behavior for browser).
  • Improve wasm test harness scripting (Node.js defaulting for CoreCLR+browser, Crossgen2 locking integration, allow precommands to compose rather than overwrite).
  • Add minor usability improvements (build script -browser/-wasi shorthands; R2RTest plumbing for --targetos; extended help output for --obj-format).

Reviewed changes

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

Show a summary per file
File Description
src/tests/readytorun/tests/mainv2.csproj Disable this test on wasm targets.
src/tests/readytorun/tests/mainv1.csproj Disable this test on wasm targets.
src/tests/readytorun/determinism/crossgen2determinism.csproj Disable determinism Crossgen2 test on wasm targets.
src/tests/readytorun/async-inline-thunks/async-inline-thunks.csproj Disable async-inline-thunks R2R test on wasm targets.
src/tests/Directory.Build.props Set CrossGen2OutputFormat=wasm for TargetOS=browser.
src/tests/Common/CoreRootArtifacts.targets Allow copying Crossgen2 executable artifacts from cross-arch output when crossgen2-published isn’t present.
src/tests/Common/CLRTest.Execute.Batch.targets Default to Node.js for CoreCLR+browser and integrate Crossgen2 lock handling in wasm/browser paths.
src/tests/Common/CLRTest.Execute.Bash.targets Default to Node.js for CoreCLR+browser and integrate Crossgen2 lock handling in wasm/browser paths.
src/tests/Common/CLRTest.CrossGen.targets Add .wasm output handling for Crossgen2 (composite + individual file modes) and pass -f when set.
src/tests/build.sh Add -browser/-wasi shorthands that also set architecture to wasm.
src/tests/build.cmd Update browser/wasi shorthand behavior to also set architecture to wasm.
src/coreclr/tools/r2rtest/Crossgen2Runner.cs Pass --targetos through to Crossgen2 when provided.
src/coreclr/tools/r2rtest/CommandLineOptions.cs Add --target-os option and plumb it into build options.
src/coreclr/tools/aot/crossgen2/Program.cs Treat PE output format as wasm when targeting Wasm32 (to avoid producing PE .dll on wasm targets).
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs Extend --help output to include --obj-format valid values/default.

Comment thread src/tests/Common/CLRTest.Execute.Bash.targets
Comment thread src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
Comment thread src/coreclr/tools/aot/crossgen2/Program.cs
Comment thread src/tests/Common/CoreRootArtifacts.targets
Copy link
Copy Markdown
Member

@kg kg left a comment

Choose a reason for hiding this comment

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

LGTM but a second pair of eyes would be good

@davidwrighton davidwrighton merged commit 662e227 into dotnet:main May 14, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr only use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants