From cbd432340205bec4cba924da91a87984f2528a37 Mon Sep 17 00:00:00 2001 From: DarumaDocker Date: Wed, 27 Nov 2024 06:25:48 +0000 Subject: [PATCH 1/2] fix(wasi): Add back unsafe block for clockid_t static variables (backport ) (cherry picked from commit 8e8a5126b2489c84a1ba8552e04abace039cbb8e) --- src/wasi/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index c749a05d08f0..f04081bad1fa 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -384,15 +384,17 @@ cfg_if! { } else { // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 #[allow(unused_unsafe)] - pub static CLOCK_MONOTONIC: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)); + pub static CLOCK_MONOTONIC: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; #[allow(unused_unsafe)] pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)); + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; #[allow(unused_unsafe)] - pub static CLOCK_REALTIME: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)); + pub static CLOCK_REALTIME: clockid_t = + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; #[allow(unused_unsafe)] pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)); + unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; } } From db206141516e687e0b2e53a53a1665d2264f04a7 Mon Sep 17 00:00:00 2001 From: DarumaDocker Date: Wed, 27 Nov 2024 07:22:08 +0000 Subject: [PATCH 2/2] fix(wasi): build verify for wasm32-wasi (backport ) (cherry picked from commit 5fc03210932398450773cfefdecd8687dd12d931) --- ci/verify-build.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 6f206f64ee47..afd87b40e4b9 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -96,6 +96,8 @@ sparc64-unknown-linux-gnu \ sparcv9-sun-solaris \ wasm32-unknown-emscripten \ wasm32-unknown-unknown \ +wasm32-wasip1 \ +wasm32-wasip2 \ x86_64-linux-android \ x86_64-unknown-freebsd \ x86_64-unknown-linux-gnu \ @@ -231,12 +233,29 @@ else no_dist_targets="" fi +case "$rust" in + "stable") supports_wasi_pn=1 ;; + "beta") supports_wasi_pn=1 ;; + "nightly") supports_wasi_pn=1 ;; + *) supports_wasi_pn=0 ;; +esac + for target in $targets; do if echo "$target" | grep -q "$filter"; then if [ "$os" = "windows" ]; then TARGET="$target" ./ci/install-rust.sh test_target "$target" else + # `wasm32-wasip1` was renamed from `wasm32-wasi` + if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then + target="wasm32-wasi" + fi + + # `wasm32-wasip2` only exists in recent versions of Rust + if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then + continue + fi + test_target "$target" fi