Repository navigation
Preserve NativeAOT WASI numeric exit codes - #135954
Merged
MichalStrehovsky merged 2 commits intoOct 19, 2026
Merged
Conversation
WASI Preview 2 libc startup calls main and returns r != 0 through the CLI run interface. Returning 100 therefore produces host exit code 1, even with Wasmtime's -S cli-exit-with-code=y: the number is already lost. Call exit explicitly so libc's _Exit uses the exit-with-code interface for statuses 0-255. The Wasmtime option is still needed to enable that interface; it does not change libc's normal-main return path. Preview 1 startup instead forwards nonzero main results to __wasi_proc_exit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a6f3a617-acae-4f4f-95d3-20b2a0bac43c
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
jkotas
approved these changes
Oct 16, 2026
This was referenced Oct 16, 2026
Closed
Member
Author
|
/ba-g widespread mutex failures; this change is not covered by CI |
MichalStrehovsky
enabled auto-merge (squash)
October 16, 2026 22:47
Member
Author
|
/ba-g widespread mutex failures; this change is not covered by CI |
2 similar comments
Member
Author
|
/ba-g widespread mutex failures; this change is not covered by CI |
Member
Author
|
/ba-g widespread mutex failures; this change is not covered by CI |
jkotas
approved these changes
Oct 19, 2026
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
Preserve the managed entry point's numeric exit code in NativeAOT WASI applications.
WASI Preview 2 libc's normal startup calls
mainand returnsr != 0through the CLI run interface. A test returning 100 consequently produces host exit code 1, even with Wasmtime's exit-with-code option: libc has already discarded the number.Call
exit(__managed__Main(...))on WASI so libc can use the numeric exit-with-code interface. Other platforms' bootstrap paths are unchanged. Wasmtime still needs-S cli-exit-with-code=yto enable that interface.Validation
On the combined local NativeAOT WASI bringup tree, including other unmerged enablement:
.\build.cmd clr.nativeaotruntime -rc Checked -lc Release -os wasi -arch wasmpassed..\src\tests\build.cmd nativeaot checked test nativeaot\SmokeTests\AttributeTrimming\AttributeTrimming.csproj wasm wasipassed.wasmtime run -W exceptions=y -S cli-exit-with-code=y .\artifacts\tests\coreclr\wasi.wasm.Checked\nativeaot\SmokeTests\AttributeTrimming\AttributeTrimming\native\AttributeTrimming.wasmreturned 100.The SDK libc startup source and installed CRT disassembly were inspected to confirm the boolean conversion. This branch contains only this cherry-picked commit from
main; it was not built independently.Note
This PR description was generated by GitHub Copilot.