Skip to content

Commit 7f0c8c5

Browse files
authored
Merge pull request #4160 from tgross35/backport-wasi-unsafe-fix
[0.2] Backports
2 parents d9a59db + db20614 commit 7f0c8c5

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

ci/verify-build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ sparc64-unknown-linux-gnu \
9696
sparcv9-sun-solaris \
9797
wasm32-unknown-emscripten \
9898
wasm32-unknown-unknown \
99+
wasm32-wasip1 \
100+
wasm32-wasip2 \
99101
x86_64-linux-android \
100102
x86_64-unknown-freebsd \
101103
x86_64-unknown-linux-gnu \
@@ -231,12 +233,29 @@ else
231233
no_dist_targets=""
232234
fi
233235

236+
case "$rust" in
237+
"stable") supports_wasi_pn=1 ;;
238+
"beta") supports_wasi_pn=1 ;;
239+
"nightly") supports_wasi_pn=1 ;;
240+
*) supports_wasi_pn=0 ;;
241+
esac
242+
234243
for target in $targets; do
235244
if echo "$target" | grep -q "$filter"; then
236245
if [ "$os" = "windows" ]; then
237246
TARGET="$target" ./ci/install-rust.sh
238247
test_target "$target"
239248
else
249+
# `wasm32-wasip1` was renamed from `wasm32-wasi`
250+
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
251+
target="wasm32-wasi"
252+
fi
253+
254+
# `wasm32-wasip2` only exists in recent versions of Rust
255+
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
256+
continue
257+
fi
258+
240259
test_target "$target"
241260
fi
242261

src/wasi/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,17 @@ cfg_if! {
384384
} else {
385385
// `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82
386386
#[allow(unused_unsafe)]
387-
pub static CLOCK_MONOTONIC: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC));
387+
pub static CLOCK_MONOTONIC: clockid_t =
388+
unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) };
388389
#[allow(unused_unsafe)]
389390
pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t =
390-
clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID));
391+
unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) };
391392
#[allow(unused_unsafe)]
392-
pub static CLOCK_REALTIME: clockid_t = clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME));
393+
pub static CLOCK_REALTIME: clockid_t =
394+
unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) };
393395
#[allow(unused_unsafe)]
394396
pub static CLOCK_THREAD_CPUTIME_ID: clockid_t =
395-
clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID));
397+
unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) };
396398
}
397399
}
398400

0 commit comments

Comments
 (0)