Repository navigation
[wasi] Enable Brotli and Zstandard on CoreCLR WASI - #136257
Conversation
Brotli was excluded on all of wasm because browser omits it for download size. WASI apps relink the native runtime with a P/Invoke table generated from the app's trimmed assemblies, so the Brotli static libraries are only pulled in when the app actually uses them. - Gate the brotli build/includes/entry points on !browser instead of !wasm. - Link libbrotlienc/libbrotlidec/libbrotlicommon in the CoreCLR WASI app relink, the NativeAOT WASI link, and the Mono WASI runtime link. - Exclude the duplicate libs.native brotli copies from the WASI CoreCLR runtime pack, matching libSystem.IO.Compression.Native.a and libz.a. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add the wasi target framework so WASI gets the real implementation instead of the PlatformNotSupported assembly, and drop wasi from the unsupported platforms of System.IO.Compression.Brotli and BrotliCompressedContent. Regenerate the WASI call helpers for the new Brotli P/Invokes: ./build.sh clr+libs+packs -os wasi -c Release -rf CoreCLR src/coreclr/vm/wasm/generate-coreclr-helpers.sh -c Release --target-os wasi Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
libzstd.a is already built for WASI and linked by the CoreCLR WASI app relink, but the managed Zstandard types were PlatformNotSupported stubs there. Compile the real implementation for wasi, expose the ZSTD entry points on !browser, and drop wasi from the unsupported platforms of the Zstandard types and ZstandardCompressedContent. The regenerated WASI call helpers now always reference libzstd, so link it unconditionally in the CoreCLR WASI relink and add it to the Mono WASI runtime link. Regenerated with: ./build.sh clr+libs+packs -os wasi -c Release -rf CoreCLR src/coreclr/vm/wasm/generate-coreclr-helpers.sh -c Release --target-os wasi Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
No pipelines are associated with this pull request. |
|
No pipelines are associated with this pull request. |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Does src\native\corehost\wasihost need to link new stuff too ? |
- Keep the libs.native compression archives in the NativeAOT WASI runtime pack: NativeAOT packs take RuntimeFiles from aotsdk rather than sharedFramework, so the WASI CoreCLR duplicate exclusion dropped them. - Update the System.IO.Compression README: Zstandard is now only unsupported on browser. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@pavelsavara No changes are needed in wasihost itself. Note This reply was generated with GitHub Copilot. |
Brotli and Zstandard now work on WASI (dotnet#136257). The decompression test servers disposed compression streams synchronously over the connection, which WASI doesn't support, and the Brotli buffer-limit test's write loop never yielded to a single-threaded client. The new Alt-Svc test needs TLS. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Enables
System.IO.Compression.Brotliand Zstandard (ZstandardStreamand related types) on CoreCLR WASI. Browser is unchanged and still excludes both.Why
Both codecs were excluded on all of wasm because browser leaves them out for download size. WASI apps always relink the native runtime with a P/Invoke table generated from the app's trimmed assemblies, so a codec's native code is only linked into apps that use it.
Measured on relinked, trimmed sample apps (Release,
wasm-tools strip -a):The GZip-only host contains no
Brotli*orZSTD_*symbols.Changes
!browserinstead of!wasm. The brotli libs are linked in the CoreCLR WASI app relink, the NativeAOT WASI link and the Mono WASI runtime link; libzstd is linked unconditionally in the CoreCLR relink. Duplicate libs.native copies are excluded from the WASI CoreCLR runtime pack, as forlibz.a.System.IO.Compression.Brotligains a-wasiTFM. System.IO.Compression compiles the real Zstandard implementation for wasi.wasiis removed fromUnsupportedOSPlatformon the Brotli assembly, the Zstandard types, andBrotliCompressedContent/ZstandardCompressedContent(src and ref).src/coreclr/vm/wasm/wasi/callhelpers-pinvoke.cppis regenerated in the commit that adds each codec's P/Invokes (Compression.Native table: 9 → 21 → 51 entries).CompressedContentTest.NonBrowser.csis compiled for WASI.Validation
CoreCLR WASI, Release, wasmtime 49.0.1:
IsMultithreadingSupportedconditions).-class CompressedContentTest: 48 run, 47 passed, 1 skipped (existing 32-bit zstdSmallestSizecase). This covers the br and zstd round-trips.mono.runtime+mono.corelib+mono.wasiruntime) builds and links.Known gaps
System.IO.Compression.Testsdoesn't target wasi because its WinZip AES and encrypted-zip tests fail there (cryptography isn't supported on WASI) and need gating first.SocketsHttpHandlerdecompression of br/zstd on WASI is covered by [wasi] Enable SocketsHttpHandler and WebSockets #136234.Related: #91279 (Brotli on browser; not addressed here)
Note
This PR description was generated with GitHub Copilot.