Skip to content

[wasi] Accept explicit return in WASI R2R host constant exports - #136243

Merged
lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasi-r2r-debug-host-return
Oct 22, 2026
Merged

lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasi-r2r-debug-host-return

Conversation

@lewing

@lewing lewing commented Oct 21, 2026

Copy link
Copy Markdown
Member

Debug builds of the WASI host compile the wasi_r2r_* accessors to i32.const N; return; end (Release emits i32.const N; end), which WasmModuleInfoReader rejected, so every Debug CoreCLR WASI ReadyToRun publish failed with The host does not export constant i32 function 'wasi_r2r_image_base'. The reader now accepts an optional return before end.

Validation (osx-arm64, wasmtime 49.0.1):

  • ./build.sh -s clr+libs+host+packs -os wasi -arch wasm -c Debug, then dotnet publish of src/mono/sample/wasi/console with -c Debug -p:RuntimeFlavor=CoreCLR -p:PublishReadyToRun=true: fails with the error above without the fix; succeeds with it (composite Wasi.Console.Sample.r2r.wasm composed into corerun), and the app runs and prints its args.
  • Same with the -c Release runtime and app: publish and run still succeed.
  • wasm-tools print of the Debug corerun confirms all five wasi_r2r_* exports have the i32.const; return shape.

There are no existing unit tests for WasmModuleInfoReader.

Note

This PR was generated with GitHub Copilot.

Debug builds of the WASI host compile the wasi_r2r_* accessors to
`i32.const X; return; end`, which WasmModuleInfoReader rejected, so
ReadyToRun composition failed with "The host does not export constant i32
function 'wasi_r2r_image_base'" for every Debug CoreCLR WASI publish.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
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.

@lewing
lewing requested a review from pavelsavara October 21, 2026 20:42
@lewing lewing added arch-wasm WebAssembly architecture area-ReadyToRun and removed area-Build-mono labels Oct 21, 2026
@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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

@lewing lewing added the os-wasi Related to WASI variant of arch-wasm label Oct 21, 2026
@lewing
lewing merged commit add98e8 into dotnet:main Oct 22, 2026
82 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 23, 2026
@lewing
lewing deleted the lewing-wasi-r2r-debug-host-return branch October 28, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-ReadyToRun os-wasi Related to WASI variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants