From 10cfcd3de01391e39e70f0a6d155a041fcdf64d3 Mon Sep 17 00:00:00 2001 From: Asger Hautop Drewsen Date: Thu, 4 Jun 2026 22:57:33 +0200 Subject: [PATCH 1/3] Fix WASI links --- compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs | 2 +- library/std/src/random.rs | 2 +- library/std/src/time.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs index f67b3b82edfac..0983327d33338 100644 --- a/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs @@ -4,7 +4,7 @@ //! "preview2". This target in rustc uses the previous version of the proposal. //! //! This target uses the syscalls defined at -//! . +//! . //! //! Note that this target was historically called `wasm32-wasi` originally and //! was since renamed to `wasm32-wasip1` after the preview2 target was diff --git a/library/std/src/random.rs b/library/std/src/random.rs index 8274060e5cedf..dc2b4691dde55 100644 --- a/library/std/src/random.rs +++ b/library/std/src/random.rs @@ -45,7 +45,7 @@ use crate::sys::random as sys; /// TEEOS | `TEE_GenerateRandom` /// UEFI | [`EFI_RNG_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.html#random-number-generator-protocol) /// VxWorks | `randABytes` after waiting for `randSecure` to become ready -/// WASI | [`random_get`](https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno) +/// WASI | [`random_get`](https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno) /// ZKVM | `sys_rand` /// /// Note that the sources used might change over time. diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 1f31ea5ced9d7..5171487c6a467 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -122,7 +122,7 @@ use crate::sys::{FromInner, IntoInner, time}; /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode -/// [__wasi_clock_time_get]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get +/// [__wasi_clock_time_get]: https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#clock_time_get /// [clock_gettime]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html /// /// **Disclaimer:** These system calls might change over time. @@ -234,7 +234,7 @@ pub struct Instant(time::Instant); /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [clock_gettime (Realtime Clock)]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html -/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get +/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#clock_time_get /// [GetSystemTimePreciseAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// From f668e32985391960faba8f931b311fb41c3e2b3c Mon Sep 17 00:00:00 2001 From: Asger Hautop Drewsen Date: Sun, 7 Jun 2026 20:48:45 +0200 Subject: [PATCH 2/3] WASI uses clock_gettime instead of __wasi_clock_time_get --- library/std/src/time.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 5171487c6a467..4dda8061a11a9 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -112,17 +112,16 @@ use crate::sys::{FromInner, IntoInner, time}; /// |-----------|----------------------------------------------------------------------| /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime] with `CLOCK_MONOTONIC` | +/// | WASI | [clock_gettime] with `CLOCK_MONOTONIC` | /// | Darwin | [clock_gettime] with `CLOCK_UPTIME_RAW` | /// | VXWorks | [clock_gettime] with `CLOCK_MONOTONIC` | /// | SOLID | `get_tim` | -/// | WASI | [__wasi_clock_time_get] with `monotonic` | /// | Windows | [QueryPerformanceCounter] | /// /// [currently]: crate::io#platform-specific-behavior /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode -/// [__wasi_clock_time_get]: https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#clock_time_get /// [clock_gettime]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html /// /// **Disclaimer:** These system calls might change over time. @@ -224,17 +223,16 @@ pub struct Instant(time::Instant); /// |-----------|----------------------------------------------------------------------| /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime (Realtime Clock)] | +/// | WASI | [clock_gettime (Realtime Clock)] | /// | Darwin | [clock_gettime (Realtime Clock)] | /// | VXWorks | [clock_gettime (Realtime Clock)] | /// | SOLID | `SOLID_RTC_ReadTime` | -/// | WASI | [__wasi_clock_time_get (Realtime Clock)] | /// | Windows | [GetSystemTimePreciseAsFileTime] / [GetSystemTimeAsFileTime] | /// /// [currently]: crate::io#platform-specific-behavior /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [clock_gettime (Realtime Clock)]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html -/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#clock_time_get /// [GetSystemTimePreciseAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// From a8a5934452596183d4ebea50bee896cf0165c022 Mon Sep 17 00:00:00 2001 From: Asger Hautop Drewsen Date: Sun, 7 Jun 2026 20:59:26 +0200 Subject: [PATCH 3/3] Link to get-random-bytes for WASIp2 and WASIp3 --- library/std/src/random.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/random.rs b/library/std/src/random.rs index dc2b4691dde55..c00dc3ecc93f4 100644 --- a/library/std/src/random.rs +++ b/library/std/src/random.rs @@ -45,7 +45,9 @@ use crate::sys::random as sys; /// TEEOS | `TEE_GenerateRandom` /// UEFI | [`EFI_RNG_PROTOCOL`](https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.html#random-number-generator-protocol) /// VxWorks | `randABytes` after waiting for `randSecure` to become ready -/// WASI | [`random_get`](https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno) +/// WASIp1 | [`random_get`](https://github.com/WebAssembly/WASI/blob/wasi-0.1/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno) +/// WASIp2 | [`get-random-bytes`] +/// WASIp3 | [`get-random-bytes`] /// ZKVM | `sys_rand` /// /// Note that the sources used might change over time. @@ -56,6 +58,7 @@ use crate::sys::random as sys; /// /// [`getrandom`]: https://www.man7.org/linux/man-pages/man2/getrandom.2.html /// [`/dev/urandom`]: https://www.man7.org/linux/man-pages/man4/random.4.html +/// [`get-random-bytes`]: https://github.com/WebAssembly/WASI/blob/main/proposals/random/imports.md#get-random-bytes-func #[doc(alias = "getrandom", alias = "getentropy", alias = "arc4random")] #[derive(Default, Debug, Clone, Copy)] #[unstable(feature = "random", issue = "130703")]