Skip to content

Commit

Permalink
Unrolled build for rust-lang#126792
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#126792 - wooden-worm:master, r=Mark-Simulacrum

wasm64 build with target-feature=+simd128,+atomics

Fixes rust-lang#126778
  • Loading branch information
rust-timer authored Jul 4, 2024
2 parents 486bc27 + 82c5cdc commit 1abba28
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions library/portable-simd/crates/core_simd/src/swizzle_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ where
use core::arch::arm::{uint8x8_t, vtbl1_u8};
#[cfg(target_arch = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_arch = "wasm64")]
use core::arch::wasm64 as wasm;
#[cfg(target_arch = "x86")]
use core::arch::x86;
#[cfg(target_arch = "x86_64")]
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
)]
#![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
#![cfg_attr(
all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"),
feature(stdarch_x86_has_cpuid)
Expand Down
17 changes: 9 additions & 8 deletions library/std/src/sys/pal/wasm/atomics/futex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::arch::wasm32;
#[cfg(target_arch = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_arch = "wasm64")]
use core::arch::wasm64 as wasm;

use crate::sync::atomic::AtomicU32;
use crate::time::Duration;

Expand All @@ -10,11 +14,8 @@ use crate::time::Duration;
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
let timeout = timeout.and_then(|t| t.as_nanos().try_into().ok()).unwrap_or(-1);
unsafe {
wasm32::memory_atomic_wait32(
futex as *const AtomicU32 as *mut i32,
expected as i32,
timeout,
) < 2
wasm::memory_atomic_wait32(futex as *const AtomicU32 as *mut i32, expected as i32, timeout)
< 2
}
}

Expand All @@ -23,12 +24,12 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
/// Returns true if this actually woke up such a thread,
/// or false if no thread was waiting on this futex.
pub fn futex_wake(futex: &AtomicU32) -> bool {
unsafe { wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
unsafe { wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, 1) > 0 }
}

/// Wake up all threads that are waiting on futex_wait on this futex.
pub fn futex_wake_all(futex: &AtomicU32) {
unsafe {
wasm32::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
wasm::memory_atomic_notify(futex as *const AtomicU32 as *mut i32, i32::MAX as u32);
}
}
8 changes: 6 additions & 2 deletions library/std/src/sys/pal/wasm/atomics/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ impl Thread {
pub fn set_name(_name: &CStr) {}

pub fn sleep(dur: Duration) {
use crate::arch::wasm32;
#[cfg(target_arch = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_arch = "wasm64")]
use core::arch::wasm64 as wasm;

use crate::cmp;

// Use an atomic wait to block the current thread artificially with a
Expand All @@ -31,7 +35,7 @@ impl Thread {
while nanos > 0 {
let amt = cmp::min(i64::MAX as u128, nanos);
let mut x = 0;
let val = unsafe { wasm32::memory_atomic_wait32(&mut x, 0, amt as i64) };
let val = unsafe { wasm::memory_atomic_wait32(&mut x, 0, amt as i64) };
debug_assert_eq!(val, 2);
nanos -= amt;
}
Expand Down

0 comments on commit 1abba28

Please sign in to comment.