Skip to content

wasm: support for wasm32-wasip2 target#12653

Open
eduardomourar wants to merge 3 commits into
uutils:mainfrom
eduardomourar:feat/support-wasm32-wasip2
Open

wasm: support for wasm32-wasip2 target#12653
eduardomourar wants to merge 3 commits into
uutils:mainfrom
eduardomourar:feat/support-wasm32-wasip2

Conversation

@eduardomourar
Copy link
Copy Markdown

@eduardomourar eduardomourar commented Jun 6, 2026

Add support for the wasm32-wasip2 (WASI Preview 2) target, enabling coreutils to compile and run on sandboxed environments that can run WebAssembly components.

Changes

  • Add wasm32-wasip2 target to CI workflows
  • Update code for wasip2 compatibility (yes, uucore and fs/display modules)
  • Adjust tests to pass on the new target
  • Update documentation and test gap tracking

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented Jun 6, 2026

But why? Is there any usecase wasip1 cannot cover? If wasip2 works on web browsers using shim, we should drop wasip1 at the same time.

@eduardomourar
Copy link
Copy Markdown
Author

The main reason to have WASI Preview 2 is because Preview 1 is not being further developed. In wasip1, we would never get full support for streams and socket. With wasip2, on other hand, we will have those as well as support for the WebAssembly Component Model. This documentation might help answering you: https://component-model.bytecodealliance.org/design/why-component-model.html#interoperability

Should we drop wasip1? Probably not yet. There are few features that are missing in Preview2:

  • std::os::wasi::prelude::OsStrExt is still under a unstable flag as discussed here
  • WASI CLI Exit with code has stabilized but it has not been implemented in rust std
  • Generated WASM component cannot be easily loaded yet in the browser. You need JCO to transpile it and include the respective WASI shims in order to have something similar to the Uutils Playground.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented Jun 6, 2026

Ok. But do you want to publish release binaries too? Or is cargo check or cargo test on the CI enough?

Comment thread tests/by-util/test_tr.rs
// On WASI the fluent translation key may appear instead of the
// translated text, but the OS error string is still present.
cmd.stderr_contains("Is a directory");
if cfg!(wasip2_runner) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it needs to be fixed

Comment thread tests/by-util/test_tr.rs
// On WASI the fluent translation key may appear instead of the
// translated text, but the OS error string is still present.
cmd.stderr_contains("Is a directory");
if cfg!(wasip2_runner) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread tests/by-util/test_rm.rs
.pipe_in("y\n")
.succeeds()
.stderr_only("rm: attempt removal of inaccessible directory 'dir'? ");
.stderr_only(if cfg!(wasi_runner) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why that ?

new_ucmd!()
.args(&["--from=iec-i", "10M"])
.fails_with_code(2)
.fails_with_code(if cfg!(wasip2_runner) { 1 } else { 2 })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why that ?

Comment thread tests/by-util/test_cat.rs
ucmd.arg("1")
.fails()
.stderr_is("cat: 1: Too many levels of symbolic links\n");
ucmd.arg("1").fails().stderr_is(if cfg!(wasi_runner) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a regression :/

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tty-eof (passes in this run but fails in the 'main' branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants