Repository navigation
[wasi] Don't copy runtime pack link inputs to app build and publish output - #135016
Merged
Merged
Conversation
…utput The WASI runtime pack's RuntimeList.xml lists its static libraries and the WasiHttpWorld .wit (and, for CoreCLR, the stock corerun) as native assets, so the SDK copied them into the bin and publish directories of every self-contained WASI app. The native link and the AppBundle read them from the runtime pack, so remove them from RuntimePackAsset/ReferenceCopyLocalPaths right after ResolveRuntimePackAssets, mirroring the browser filtering in AssetsComputingHelper.ShouldFilterCandidate. Co-authored-by: Copilot App <[email protected]>
|
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
marked this pull request as ready for review
October 1, 2026 13:27
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
lewing
marked this pull request as draft
October 1, 2026 13:29
lewing
marked this pull request as ready for review
October 1, 2026 13:29
maraf
approved these changes
Oct 1, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The WASI runtime pack's
data/RuntimeList.xmllists the pack's link-time inputs as<File Type="Native" />: the static libraries (18.afor CoreCLR, 23 for Mono),WasiHttpWorld_component_type.witon Mono, and the stockcorerunon CoreCLR. The SDK treats these as native runtime assets of a self-contained app. It adds them toReferenceCopyLocalPathsand toResolvedFileToPublish, so every WASI app gets one copy inbin/.../wasi-wasm/and another inpublish/. Nothing reads those copies. The native link (Mono's_WasiWriteRspForLinking, CoreCLR's_WasiCoreCLRRelinkCoreRun) reads the.aand.witfiles from$(MicrosoftNetCoreAppRuntimePackRidNativeDir). On CoreCLR, the AppBundle'smanaged/corerunis the per-app relinked or R2R-composed host, not the pack'scorerun.Browser doesn't have this problem.
ComputeWasmBuildAssets/ComputeWasmPublishAssetsfilter runtime-pack candidates throughAssetsComputingHelper.ShouldFilterCandidate. The WASI targets don't use that pipeline.Change
src/mono/wasi/build/WasiApp.targets, shared by Mono and CoreCLR (WasiApp.CoreCLR.targetsimports it). A new_WasiRemoveRuntimePackLinkInputstarget runsAfterTargets="ResolveRuntimePackAssets". It removes the runtime pack's native assets with extensions.a,.o,.c,.h,.rsp,.props,.wit, andwasm-props.json(the browser rules that apply to WASI, plus.wit), and on CoreCLR the stockcorerun. They're removed fromRuntimePackAssetandReferenceCopyLocalPaths. Removing them fromRuntimePackAssetkeeps them out of_ResolvedCopyLocalPublishAssets(and thereforeResolvedFileToPublish) and out of the generated.deps.json. OnlyRuntimePackAssetitems are matched, so app-providedNativeFileReferenceitems aren't touched.The target is conditioned on
'@(RuntimePackAsset)' != ''.WasmNestedPublishApprequestsResolveRuntimePackAssetsbefore@(RuntimePack)is populated, so that first request is skipped by its condition, but itsAfterTargetsstill fire. Without the item condition, this target would run with nothing to remove and be marked done. The.afiles would then reach the nested publish'sbincopy andpublish/. With the condition, it stays un-run until the real resolution.Notes:
.o,.c,.h,.rsp,.props, andwasm-props.jsonaren't currently in either WASI pack's RuntimeList (Mono shipssrc/*.c,include/**/*.h,src/*.rsp, andsrc/wasm-props.jsonin the pack, but they aren't listed). They're filtered so the WASI rules match browser's and stay correct if those files get listed.icudt.datanddotnet.wasmremovals in_GetWasiGenerateAppBundleDependenciesrun after copy-local and publish have computed their lists, so they don't affectbin/orpublish/. Theicudt_CJK/EFIGS/no_CJKshards are still copied. They're runtime data, not link inputs.eng/targetingpacks.targetsaddswasi-wasmonly to the Mono-labeledKnownRuntimePack. Product apps (the workload addswasi-wasmtoKnownRuntimePack), in-tree Mono, and [wasi] Add CoreCLR ReadyToRun library and runtime test CI #134813 do resolve it.Validation
Local, macOS arm64 host, wasi-sdk 33, wasmtime via xharness. Suite:
Microsoft.Extensions.Primitives.Tests. Measured underartifacts/bin/Microsoft.Extensions.Primitives.Tests/Release/net11.0/wasi-wasm: top-level files forbin, all files forpublish. "Before" reverts only this change.Builds:
./build.sh -s clr+libs+host+packs -os wasi -arch wasm -rf CoreCLR -c Release→ succeeded, 0 errors./build.sh -s mono+libs -os wasi -arch wasm -c Release→ succeeded, 0 errors (one retry after a transient compiler-serverCannot release a lockerror)Base command:
./dotnet.sh build src/libraries/Microsoft.Extensions.Primitives/tests/Microsoft.Extensions.Primitives.Tests.csproj -f net11.0 /p:TargetOS=wasi /p:TargetArchitecture=wasm /p:Configuration=Release /p:RuntimeFlavor=<flavor> [extra].a= 66.5 MB + 33.5 MBcorerun)/p:TestWasmReadyToRun=true /p:EnableAggressiveTrimming=true(2).a= 26.8 MB +.wit)Per app, this saves about 200 MB on CoreCLR and about 53 MB on Mono across
binandpublish. The removed files are exactly the.afiles pluscorerun(CoreCLR) or.wit(Mono). The AppBundle file list and every file size are identical before and after in all three scenarios. CoreCLRAppBundle/managed/corerunis still the per-app host: 34,743,522 bytes relinked (interpreter) and 77,201,799 bytes composed (R2R), compared with the pack's 35,096,355-byte stockcorerun.Test runs with the change (
/t:Testadded to the command above), via xharness/wasmtime:Tests run: 541 Passed: 538 Failed: 0 Skipped: 3Tests run: 541 Passed: 538 Failed: 0 Skipped: 3(composite: 88,191 functions)Tests run: 541 Passed: 538 Failed: 0 Skipped: 3/p:WasmBuildNative=true(per-app relink ofdotnet.wasmfrom the pack's.a/.wit) →Tests run: 541 Passed: 538 Failed: 0 Skipped: 3(1) Upstream main doesn't resolve the CoreCLR WASI runtime pack in-tree, so for this row I applied #134813's three-line
eng/targetingpacks.targetschange locally. It isn't part of this PR.(2) R2R with trimming needs #134813's framework-resolution changes (with only the
targetingpacks.targetschange, crossgen2's call-helper generator fails on mixed trimmed and untrimmed framework assemblies, independent of this PR). I validated it on a temporary local merge of #134813 into this branch, rebuilt with the samebuild.shcommand.Note
This PR description and change were generated with GitHub Copilot.