about summary refs log tree commit diff
path: root/library/std/src/sys/pal/wasip2
AgeCommit message (Collapse)AuthorLines
2025-09-13also apply revert to wasip2Ralf Jung-18/+7
2025-09-10std: move `thread` into `sys`joboet-2/+1
2025-09-08std: move `thread` into `sys` (rename only)joboet-73/+0
2025-08-28std: Start supporting WASIp2 nativelyAlex Crichton-4/+144
This commit is the start of an effort to support WASIp2 natively in the standard library. Before this commit the `wasm32-wasip2` target behaved exactly like `wasm32-wasip1` target by importing APIs from the core wasm module `wasi_snapshot_preview1`. These APIs are satisfied by the `wasm-component-ld` target by using an [adapter] which implements WASIp1 in terms of WASIp2. This adapter comes at a cost, however, in terms of runtime indirection and instantiation cost, so ideally the adapter would be removed entirely. The purpose of this adapter was to provide a smoother on-ramp from WASIp1 to WASIp2 when it was originally created. The `wasm32-wasip2` target has been around for long enough now that it's much more established. Additionally the only thing historically blocking using WASIp2 directly was implementation effort. Work is now underway to migrate wasi-libc itself to using WASIp2 directly and now seems as good a time as any to migrate the Rust standard library too. Implementation-wise the milestones here are: * The `wasm32-wasip2` target now also depends on the `wasi` crate at version 0.14.* in addition to the preexisting dependency of 0.11.*. The 0.14.* release series binds WASIp2 APIs instead of WASIp1 APIs. * Some preexisting naming around `mod wasi` or `wasi.rs` was renamed to `wasip1` where appropriate. For example `std::sys::pal::wasi` is now called `std::sys::pal::wasip1`. * More platform-specific WASI modules are now split between WASIp1 and WASIp2. For example getting the current time, randomness, and process arguments now use WASIp2 APIs directly instead of using WASIp1 APIs that require an adapter. It's worth pointing out that this PR does not migrate the entire standard library away from using WASIp1 APIs on the `wasm32-wasip2` target. Everything related to file descriptors and filesystem APIs is still using WASIp1. Migrating that is left for a future PR. In the meantime the goal of this change is to lay the groundwork necessary for migrating in the future. Eventually the goal is to drop the `wasi` 0.11.* dependency on the `wasm32-wasip2` target (the `wasm32-wasip1` target will continue to retain this dependency). [adapter]: https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-preview1-component-adapter/README.md
2025-04-18Combine env consts into std::sys::env_constsThalia Archibald-2/+0
2025-04-12Move args into std::sysThalia Archibald-2/+0
2025-04-04Move fd into sysThalia Archibald-4/+1
2025-03-22std: move process implementations to `sys`joboet-2/+0
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-09std: move stdio to `sys`joboet-2/+0
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.
2025-03-08Move fs into sysThalia Archibald-2/+0
2025-02-13std: Apply unsafe_attr_outside_unsafeEric Huss-1/+1
2025-02-07std: move `io` module out of `pal`joboet-2/+0
2025-02-02std: move network code into `sys`joboet-418/+0
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2024-11-26std: update internal uses of `io::const_error!`joboet-1/+1
2024-10-09Decouple WASIp2 sockets from WasiFdNicola Krumschmidt-18/+56
2024-09-29Hook up std::net to wasi-libc on wasm32-wasip2 targetNicola Krumschmidt-1/+379
2024-09-23std: implement the `random` featurejoboet-1/+1
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-08-27std: move allocators to `sys`joboet-2/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-17Avoid comments that describe multiple `use` items.Nicholas Nethercote-3/+6
There are some comments describing multiple subsequent `use` items. When the big `use` reformatting happens some of these `use` items will be reordered, possibly moving them away from the comment. With this additional level of formatting it's not really feasible to have comments of this type. This commit removes them in various ways: - merging separate `use` items when appropriate; - inserting blank lines between the comment and the first `use` item; - outright deletion (for comments that are relatively low-value); - adding a separate "top-level" comment. We also entirely skip formatting for four library files that contain nothing but `pub use` re-exports, where reordering would be painful.
2024-06-15std: refactor the TLS implementationjoboet-4/+0
As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. @rustbot label +A-thread-locals
2024-05-02std: move thread parking to `sys::sync`joboet-9/+0
2024-03-13Provide `cabi_realloc` on `wasm32-wasip2` by defaultAlex Crichton-0/+67
This commit provides a component model intrinsic in the standard library by default on the `wasm32-wasip2` target. This intrinsic is not required by the component model itself but is quite common to use, for example it's needed if a wasm module receives a string or a list. The intention of this commit is to provide an overridable definition in the standard library through a weak definition of this function. That means that downstream crates can provide their own customized and more specific versions if they'd like, but the standard library's version should suffice for general-purpose use.
2024-03-13Get wasm32-wasip2 compiling with its custom pal implementationAlex Crichton-6/+0
The ordering of targets in `pal/mod.rs` did not end up using the wasip2 implementation, so after reordering that I've edited the implementation to compile correctly.
2024-03-12std: move `Once` implementations to `sys`joboet-4/+0
2024-02-27Rename wasm32-wasi-preview2 to wasm32-wasip2Ryan Levick-0/+78
Signed-off-by: Ryan Levick <me@ryanlevick.com>