Skip to content

Commit 57dfd5b

Browse files
authored
Merge pull request #4157 from DarumaDocker/main
fix(wasi): Add back unsafe block for clockid_t static variables
2 parents 511e3f2 + 5fc0321 commit 57dfd5b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

ci/verify-build.sh

+19
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ sparc64-unknown-linux-gnu \
9595
sparcv9-sun-solaris \
9696
wasm32-unknown-emscripten \
9797
wasm32-unknown-unknown \
98+
wasm32-wasip1 \
99+
wasm32-wasip2 \
98100
x86_64-linux-android \
99101
x86_64-unknown-freebsd \
100102
x86_64-unknown-linux-gnu \
@@ -227,12 +229,29 @@ else
227229
no_dist_targets=""
228230
fi
229231

232+
case "$rust" in
233+
"stable") supports_wasi_pn=1 ;;
234+
"beta") supports_wasi_pn=1 ;;
235+
"nightly") supports_wasi_pn=1 ;;
236+
*) supports_wasi_pn=0 ;;
237+
esac
238+
230239
for target in $targets; do
231240
if echo "$target" | grep -q "$filter"; then
232241
if [ "$os" = "windows" ]; then
233242
TARGET="$target" ./ci/install-rust.sh
234243
test_target "$target"
235244
else
245+
# `wasm32-wasip1` was renamed from `wasm32-wasi`
246+
if [ "$target" = "wasm32-wasip1" ] && [ "$supports_wasi_pn" = "0" ]; then
247+
target="wasm32-wasi"
248+
fi
249+
250+
# `wasm32-wasip2` only exists in recent versions of Rust
251+
if [ "$target" = "wasm32-wasip2" ] && [ "$supports_wasi_pn" = "0" ]; then
252+
continue
253+
fi
254+
236255
test_target "$target"
237256
fi
238257

src/wasi/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,17 @@ cfg_if! {
384384
} else {
385385
// unsafe code here is required in the stable, but not in nightly
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)