Allow compiling the wasm32-wasi std library with atomics

The issue #102157 demonstrates how currently the `-Z build-std` option
will fail when re-compiling the standard library with `RUSTFLAGS` like
`RUSTFLAGS="-C target-feature=+atomics,+bulk-memory -C
link-args=--shared-memory"`. This change attempts to resolve those build
issues by depending on the the WebAssembly `futex` module and providing
an implementation for `env_lock`. Fixes #102157.
This commit is contained in:
Andrew Brown 2022-09-27 11:50:47 -07:00
parent 0265a3e93b
commit da638b3a9f
2 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,9 @@
pub mod env;
pub mod fd;
pub mod fs;
#[allow(unused)]
#[path = "../wasm/atomics/futex.rs"]
pub mod futex;
pub mod io;
#[path = "../unsupported/locks/mod.rs"]
pub mod locks;

View File

@ -24,11 +24,16 @@ mod libc {
}
}
#[cfg(not(target_feature = "atomics"))]
pub unsafe fn env_lock() -> impl Any {
cfg_if::cfg_if! {
if #[cfg(target_feature = "atomics")] {
todo!()
} else {
// No need for a lock if we're single-threaded, but this function will need
// to get implemented for multi-threaded scenarios
}
}
}
pub fn errno() -> i32 {
extern "C" {