Repository navigation
feat(wasi): normalize wasi error codes - #13625
eduardomourar wants to merge 5 commits into
Conversation
|
GNU testsuite comparison: |
|
Can we avoid introducing many code with |
Merging this PR will improve performance by 7.8%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
ecc7c96 to
650e875
Compare
I had to create 3 separate functions to deal with normalizing the WASI errors, but I think it does what you asked. |
9752428 to
d311b90
Compare
364e289 to
0d592ff
Compare
WASI reports directory errors and broken pipes with different errno values than Unix. Add `wasi_normalize_open_error`, `wasi_normalize_read_error` and `wasi_is_broken_pipe` to map them to the Unix `ErrorKind`. The functions do nothing on other targets.
Use the new `uucore::error` helpers in cat, dd, rm, wc, tee, sort, seq, tr, tsort and split. These utilities now report `IsADirectory` on WASI instead of a raw errno. seq also detects the preview 2 broken pipe. Add WASI fallbacks for APIs that WASI does not provide: the `dd` progress reporter and alarm without threads, `OwnedFileDescriptorOrHandle` without descriptor duplication, and directory checks in rm and tsort.
Add integration tests for the WASI behavior. Ignore the tests that the WASI sandbox cannot run and give each a reason. Build relative symlink targets in the test harness on WASI. Add the `UUTESTS_WASM_RUNNER_ARGS` variable. Run the wasip2 integration suite in `wasi.yml` and extend the utility list. Document the ignore reasons in `docs/src/wasi-test-gaps.md`.
Use nightly for wasm32-wasip2. Only nightly keeps the exit code in `std::process::exit`.
Remove the directory error normalization from cat, dd and rm. Remove `wasi_is_broken_pipe`, because seq now gets `BrokenPipe` on preview 2. tee, tr and wc keep their mappings, because their tests still fail without them. Revert the WASI `OwnedFileDescriptorOrHandle::from` in uucore. dd now takes ownership of the stdout descriptor itself, because WASI cannot duplicate descriptors. Fix the `USimpleError` import for WASI in dd and two clippy warnings.
0d592ff to
aa5fe0c
Compare
Continuation of #12653. Aligns error handling on wasm32-wasip1/wasm32-wasip2 with native Unix behavior, and enables the wasip2 integration test suite.