rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
94.81k stars 12.22k forks source link

wasm64: std fails to build with `target-feature=+atomics` #126778

Closed wooden-worm closed 1 day ago

wooden-worm commented 2 weeks ago

I tried to build an example project for wasm64-unknown-unknown with target-feature=+atomics, but the std failed to build due to https://github.com/rust-lang/rust/blob/7a08f84627ff3035de4d66ff3209e5fc93165dcb/library/std/src/sys/pal/wasm/atomics/futex.rs#L1 and https://github.com/rust-lang/rust/blob/7a08f84627ff3035de4d66ff3209e5fc93165dcb/library/std/src/sys/pal/wasm/atomics/thread.rs#L22 hardcoding wasm32 arch.

I could get std to build by adding #![feature(simd_wasm64)] to https://github.com/rust-lang/rust/blob/master/library/std/src/lib.rs, and a few cfg checks to import the correct module.

I could work on a PR if that's the right approach.

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (d7f6ebace 2024-06-16)
binary: rustc
commit-hash: d7f6ebacee13b6c03623c4b74197280454ede8de
commit-date: 2024-06-16
host: aarch64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
wooden-worm commented 2 weeks ago

There's another similar problem with building for wasm64 using target-feature=+simd128: portable-simd only supports wasm32

https://github.com/rust-lang/rust/blob/4e6de37349c7838df095b085a2640cb6a007c96a/library/portable-simd/crates/core_simd/src/swizzle_dyn.rs#L31

workingjubilee commented 2 weeks ago

that sounds about right as a fix. feel free to PR it!