Repository navigation
[wasi] Enable CoreCLR WASI composite ReadyToRun publishing #133265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # CoreCLR-WASI composite ReadyToRun | ||
|
|
||
| This is an experimental in-tree publishing workflow. The shipping WASI SDK | ||
| does not yet select the CoreCLR app builder. | ||
|
|
||
| WASI requires the compiled composite to be composed into the host component before execution. | ||
| Copying `composite-r2r.wasm` beside an unmodified host is not sufficient. Composition is | ||
| implemented by the in-tree `ComposeWasiReadyToRun` MSBuild task. | ||
| The [WebCIL design document](../../../design/mono/webcil.md#wasi-host-composition) describes | ||
| the image layout and host contract. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Build prerequisites are described in the [CoreCLR build guide](README.md). | ||
| Composition additionally requires `wasm-tools` and Binaryen's `wasm-merge` and `wasm-opt`. | ||
| Running the result requires wasmtime with WebAssembly exception support. | ||
| In-tree publishing acquires pinned tool versions into the shared wasm tool cache through | ||
| `eng/AcquireWasiR2RTools.targets`. | ||
|
|
||
| Framework-sized composites can require several GiB of memory during composition. Allow for the | ||
| host and composite working sets when sizing build containers. | ||
|
|
||
| ## Publishing | ||
|
|
||
| Build the runtime, libraries, and packs, then publish an in-tree WASI project: | ||
|
|
||
| ```bash | ||
| ./build.sh -s clr+libs+packs -os wasi -arch wasm -c Release | ||
| ./dotnet.sh publish <project> -c Release -p:TargetOS=wasi \ | ||
| -p:RuntimeFlavor=CoreCLR -p:PublishReadyToRun=true | ||
| ``` | ||
|
|
||
| The app builder enables composite R2R, compiles the app/framework closure, sizes the host's image | ||
| buffer and table reservation, links the host, and invokes the composer. It deploys the composed | ||
| host and the per-assembly stubs under the app bundle's `managed/` directory. | ||
| Non-composite R2R and `WasmSingleFileBundle` are not supported by this path. | ||
|
|
||
| ## Composer diagnostics | ||
|
|
||
| The build targets generate Crossgen2 response files; a hand-maintained response-file template | ||
| is not required. The host supplies the image and table bases, and the C# composer rejects an | ||
| undersized buffer, overlapping table reservation, or a non-self-installing composite. | ||
|
|
||
| A valid composed module and a successful run alone do not prove R2R was used. Enable the guest's | ||
| `DOTNET_ReadyToRunLogFile` and look for `Ready to Run initialized successfully` for the app | ||
| assemblies. This confirms image loading; proving a particular method executes compiled code | ||
| requires a breakpoint or trace in that method's wasm body. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <!-- | ||
| Acquires the host tools used to compose a CoreCLR-WASI composite ReadyToRun image into the app | ||
| host (wasm-tools, and Binaryen's wasm-merge and wasm-opt) into the shared cache described in | ||
| eng/wasm/WasmToolCache.props. | ||
| --> | ||
| <Project> | ||
| <PropertyGroup> | ||
| <_WasiR2RToolOS Condition="'$(HostOS)' == 'linux'">linux</_WasiR2RToolOS> | ||
| <_WasiR2RToolOS Condition="'$(HostOS)' == 'osx'">macos</_WasiR2RToolOS> | ||
| <_WasiR2RToolArch Condition="'$(BuildArchitecture)' == 'x64'">x86_64</_WasiR2RToolArch> | ||
| <_WasiR2RToolArch Condition="'$(BuildArchitecture)' == 'arm64'">aarch64</_WasiR2RToolArch> | ||
| <_BinaryenArch>$(_WasiR2RToolArch)</_BinaryenArch> | ||
| <_BinaryenArch Condition="'$(HostOS)' == 'osx' and '$(BuildArchitecture)' == 'arm64'">arm64</_BinaryenArch> | ||
| <_BinaryenArchiveName>binaryen-version_$(BinaryenVersion)-$(_BinaryenArch)-$(_WasiR2RToolOS)</_BinaryenArchiveName> | ||
| <_WasmToolsArchiveName>wasm-tools-$(WasmToolsVersion)-$(_WasiR2RToolArch)-$(_WasiR2RToolOS)</_WasmToolsArchiveName> | ||
|
|
||
| <_BinaryenSha256 Condition="'$(WasmToolHostRid)' == 'linux-x64'">0a18362361ad05465118cd8eeb72edaeec89de6894bc283576ef4e07aa3babcc</_BinaryenSha256> | ||
| <_BinaryenSha256 Condition="'$(WasmToolHostRid)' == 'linux-arm64'">e6ae6e09ac40f4e14bc5be6f687c58e2995c84170013975fa641809dd3b480a0</_BinaryenSha256> | ||
| <_BinaryenSha256 Condition="'$(WasmToolHostRid)' == 'osx-x64'">d3e2d1235b70c93c54b52eabc1625ea960965152218754f1f4eeb0f873c48e03</_BinaryenSha256> | ||
| <_BinaryenSha256 Condition="'$(WasmToolHostRid)' == 'osx-arm64'">79d3ab9f417d9e215f15f598f523d001a7d9ac1e59367e5c869fbdabd1cba72e</_BinaryenSha256> | ||
|
|
||
| <_WasmToolsSha256 Condition="'$(WasmToolHostRid)' == 'linux-x64'">4e2898f7ca3bd0536218ed9b7b36ff7b86954c57ae0e6272fde69728cbe01088</_WasmToolsSha256> | ||
| <_WasmToolsSha256 Condition="'$(WasmToolHostRid)' == 'linux-arm64'">4a9a1c6a0885aaf17f433f2927bd61b1fe40069836f750f4e9f9ccd661106c65</_WasmToolsSha256> | ||
| <_WasmToolsSha256 Condition="'$(WasmToolHostRid)' == 'osx-x64'">9e311880fe8fcb7ef55cfeea98dc6235440a0aa0a66373affdda4bc1dde47602</_WasmToolsSha256> | ||
| <_WasmToolsSha256 Condition="'$(WasmToolHostRid)' == 'osx-arm64'">27b5f83d82ae8f2d961b5a87bdc024bca9db851a7b617d14065cec196fed29d7</_WasmToolsSha256> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- Composition runs on the build host, not on the wasm target. Use the same | ||
| version/host-keyed cache and atomic acquisition as wasi-sdk and wasmtime. --> | ||
| <Target Name="AcquireWasiR2RTools"> | ||
| <Error Condition="'$(_WasiR2RToolOS)' == '' or '$(_WasiR2RToolArch)' == ''" | ||
| Text="WASI R2R tool acquisition requires a Linux or macOS x64/arm64 host, not $(WasmToolHostRid)." /> | ||
| <Error Condition="'$(_BinaryenSha256)' == '' or '$(_WasmToolsSha256)' == ''" | ||
| Text="WASI R2R tool acquisition has no SHA-256 hashes for host $(WasmToolHostRid)." /> | ||
|
|
||
| <MSBuild Projects="$(RepositoryEngineeringDir)wasm\AcquireWasmTool.proj" | ||
| Targets="AcquireWasmTool" | ||
| Properties="WasmToolName=Binaryen $(BinaryenVersion); | ||
| WasmToolUrl=https://github.com/WebAssembly/binaryen/releases/download/version_$(BinaryenVersion)/$(_BinaryenArchiveName).tar.gz; | ||
| WasmToolSha256=$(_BinaryenSha256); | ||
| WasmToolKind=targz; | ||
| WasmToolInnerDir=binaryen-version_$(BinaryenVersion); | ||
| WasmToolCacheEntryDir=$(BinaryenCacheDir); | ||
| WasmToolStampFile=$(BinaryenStampFile); | ||
| WasmToolVerify=$(BinaryenCacheDir)bin/wasm-merge; | ||
| WasmToolChmod=$(BinaryenCacheDir)bin/wasm-merge; | ||
| WasmToolDownloadDir=$(WasmToolDownloadDir); | ||
| HostOS=$(HostOS)" /> | ||
| <Error Condition="!Exists('$(BinaryenCacheDir)bin/wasm-opt')" | ||
| Text="The Binaryen $(BinaryenVersion) cache entry is missing wasm-opt: $(BinaryenCacheDir)" /> | ||
|
|
||
| <MSBuild Projects="$(RepositoryEngineeringDir)wasm\AcquireWasmTool.proj" | ||
| Targets="AcquireWasmTool" | ||
| Properties="WasmToolName=wasm-tools $(WasmToolsVersion); | ||
| WasmToolUrl=https://github.com/bytecodealliance/wasm-tools/releases/download/v$(WasmToolsVersion)/$(_WasmToolsArchiveName).tar.gz; | ||
| WasmToolSha256=$(_WasmToolsSha256); | ||
| WasmToolKind=targz; | ||
| WasmToolInnerDir=$(_WasmToolsArchiveName); | ||
| WasmToolCacheEntryDir=$(WasmToolsCacheDir); | ||
| WasmToolStampFile=$(WasmToolsStampFile); | ||
| WasmToolVerify=$(WasmToolsCacheDir)wasm-tools; | ||
| WasmToolChmod=$(WasmToolsCacheDir)wasm-tools; | ||
| WasmToolDownloadDir=$(WasmToolDownloadDir); | ||
| HostOS=$(HostOS)" /> | ||
| </Target> | ||
| </Project> | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.