Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wasi): Add back unsafe block for clockid_t static variables #4157

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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 \
Expand Down Expand Up @@ -227,12 +229,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

Expand Down
10 changes: 6 additions & 4 deletions src/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,17 @@ cfg_if! {
} else {
// unsafe code here is required in the stable, but not in nightly
#[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)) };
}
}

Expand Down