Skip to content

Wasip3: File handing implementation#757

Merged
alexcrichton merged 1 commit intoWebAssembly:mainfrom
alexcrichton:wasip3-files
Mar 3, 2026
Merged

Wasip3: File handing implementation#757
alexcrichton merged 1 commit intoWebAssembly:mainfrom
alexcrichton:wasip3-files

Conversation

@alexcrichton
Copy link
Collaborator

This is an initial implementation of some basic file-handling functions such as reading, writing, opening directories, iterating them, etc. A number of previously failing tests are now passing and the wasip2_file.c implementation is now merged with WASIp3 with file.c. Bindings generation is also updated to flag some specific functions as being lowered synchronously as libc always blocks on the result.

Note that much of this PR is primarily authored by @cpetig. I've rebased, squashed, and applied my own review comments from #720 to this. Notably some small edge cases here and there are handled and like with other files wasip{2,3}_file.c has now simply become file.c with both versions living in the same file.

@alexcrichton alexcrichton requested a review from dicej March 3, 2026 21:28
}
if (file->write_subtask != 0) {
// TODO: this should use `wasip3_subtask_cancel` but right now that's buggy
// in Wasmtime. For now assume closign the stream above is enough to have
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// in Wasmtime. For now assume closign the stream above is enough to have
// in Wasmtime. For now assume closing the stream above is enough to have

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, is there an issue URL we can reference here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point yeah, this was fixed in bytecodealliance/wasmtime#12640 so I left a note here that 43.0.0 will be sufficient to change this.

This is an initial implementation of some basic file-handling functions
such as reading, writing, opening directories, iterating them, etc. A
number of previously failing tests are now passing and the
`wasip2_file.c` implementation is now merged with WASIp3 with `file.c`.
Bindings generation is also updated to flag some specific functions as
being lowered synchronously as libc always blocks on the result.

Co-authored-by: Christof Petig <christof.petig@arcor.de>
@alexcrichton
Copy link
Collaborator Author

The new stdio test I wrote is running afoul of bytecodealliance/wasmtime#12711, so I'm going to remove the test from this PR and defer it to once Wasmtime 43 is released.

@alexcrichton alexcrichton enabled auto-merge (squash) March 3, 2026 22:43
@alexcrichton alexcrichton merged commit 58fa18a into WebAssembly:main Mar 3, 2026
29 checks passed
@alexcrichton alexcrichton deleted the wasip3-files branch March 3, 2026 22:49
alexcrichton added a commit that referenced this pull request Mar 3, 2026
This is a further extension of #757 to implement much more functionality
in wasi-libc related to filesystems for the `wasm32-wasip3` target. This
largely reuses the `wasm32-wasip2` implementations of things by
generated bindings in non-async mode. The end result of this is a whole
slew of tests are now passing on the p3 target.
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.

2 participants