[WASI][Mono] Enable Mono AOT on WASI in runtime-wasm CI leg#129098
Open
pavelsavara wants to merge 6 commits into
Open
[WASI][Mono] Enable Mono AOT on WASI in runtime-wasm CI leg#129098pavelsavara wants to merge 6 commits into
pavelsavara wants to merge 6 commits into
Conversation
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Mono WASI runtime and WASM CI/test configuration to improve coverage and avoid early startup issues when using AOT on WASI.
Changes:
- Enable lazy loading of assemblies referenced by AOT images during WASI runtime initialization to avoid early-resolution reentrancy.
- Disable the default
EventSourceSupport=truesetting for WASI in browser/WASM test targets. - Configure the
runtime-wasmpipeline wrapper to include optional jobs by settingexcludeOptional: false.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/mono/wasi/runtime/driver.c | Sets mono_opt_aot_lazy_assembly_load during WASI runtime startup (plus adds an extern declaration). |
| eng/testing/tests.browser.targets | Avoids enabling EventSourceSupport by default when TargetOS is wasi. |
| eng/pipelines/runtime-wasm.yml | Forces optional wasm jobs on by passing excludeOptional: false into the wasm job template. |
eb87af3 to
68145f1
Compare
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- src/mono/sample/wasi/jco/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
src/mono/wasi/runtime/driver.c:262
- monoeg_g_getenv() can return NULL (see main.c usage), but this code unconditionally passes the result to strcmp(). If DOTNET_SYSTEM_GLOBALIZATION_INVARIANT is unset, this will dereference NULL and crash during runtime initialization.
char* invariant_globalization = monoeg_g_getenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
if (strcmp(invariant_globalization, "true") != 0 && strcmp(invariant_globalization, "1") != 0)
load_icu_data();
Member
Author
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change enables Mono AOT for the WASI target and fixes the test
infrastructure and test gating that the AOT-trimmed WASI builds need.
The core runtime fix is a single line in the WASI driver that defers eager
assembly loading from AOT images. The remaining changes adapt the build
pipelines, AOT test build flow, and platform-detection / test gating so the
trimmed WASI test legs pass.
Motivation
Mono AOT on WASI previously aborted during startup with:
On WASI, assemblies are resolved through filesystem probing, which is not yet
available while corlib itself is being set up. Eagerly loading the assemblies
referenced by corlib's AOT image (e.g.
System.Security.Claims) during thatearly phase falls back to the managed
AssemblyLoadContextresolving event,which needs corlib metadata that isn't initialized yet — a reentrancy that
aborts startup.
Changes
Runtime
src/mono/wasi/runtime/driver.c— Setmono_opt_aot_lazy_assembly_load = 1inmono_wasm_load_runtime. This loadsassemblies referenced by AOT images lazily (when actually needed) instead of
eagerly, avoiding the early-startup reentrancy described above. A comment
documents the rationale.
Build / test infrastructure
eng/testing/tests.wasm.targets— Skip importing theBrowserWasmApp.targets-based local AOT proxy logic on WASI(
'$(TargetOS)' != 'wasi'), since WASI uses its own AOT build flow.eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml—RunWasmSamples=falsefor the WASI smoke and AOT legs.shouldRunSmokeOnly: true).eng/pipelines/runtime-wasm.yml— AddexcludeOptional: falseso theWASM-only pipeline runs the WASI legs.
Platform detection & test gating
PlatformDetection.cs—IsBuiltWithAggressiveTrimmingnow includesIsWasi. WASI apps always build withTrimMode=full, but the non-AOTLibraryTestsleg did not embed the substitution that flips this flag, so itreported
false. UsingIsWasi(notIsWasm) keeps Browser non-AOTuntrimmed.
NumberFormatInfoTests.cs—FullICUPlatformnow uses!PlatformDetection.IsWasminstead ofIsNotBrowser, so the WASI target(which also lacks full ICU) is excluded.
DataContractJsonSerializer.cs/DataContractSerializer.cs— Gate theFileStreamSurrogatetests with[SkipOnPlatform(TestPlatforms.Wasi, ...)]./tmpis not preopened in thewasmtime --dir .sandbox, soTempFile.Create()cannot create temp files.Cleanup
src/mono/sample/wasi/jcosample (Program.cs, csproj,main.mjs, package.json, package-lock.json,
.npmrc).