about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-04-26 01:55:52 -0500
committerGitHub <noreply@github.com>2023-04-26 01:55:52 -0500
commit3fbaf789bdc59ee491eb20fe7b40ea66cf6cc3ad (patch)
tree26e965242fe2639f46facde72e63e505aeff97ab
parent3163dfd1cd71487a5eb54d2f7c07bc2e1ef85d6a (diff)
parent01c4f319276da912dd2be768ae0ce9857ad6bb63 (diff)
downloadrust-3fbaf789bdc59ee491eb20fe7b40ea66cf6cc3ad.tar.gz
rust-3fbaf789bdc59ee491eb20fe7b40ea66cf6cc3ad.zip
Rollup merge of #110587 - tomaka:fix-109727, r=jyn514
Fix `std` compilation error for wasi+atomics

Fix https://github.com/rust-lang/rust/issues/109727

It seems that the `unsupported/once.rs` module isn't meant to exist at the same time as the `futex` module, as they have conflicting definitions.

I've solved this by defining the `once` module only if `not(target_feature = "atomics")`.
The `wasm32-unknown-unknown` target [similarly only defines the `once` module if `not(target_feature = "atomics")`](https://github.com/tomaka/rust/blob/01c4f319276da912dd2be768ae0ce9857ad6bb63/library/std/src/sys/wasm/mod.rs#L69-L70).

As show in [this block of code](https://github.com/tomaka/rust/blob/01c4f319276da912dd2be768ae0ce9857ad6bb63/library/std/src/sys_common/once/mod.rs#L10-L34), the `sys::once` module doesn't need to exist if `all(target_arch = "wasm32", target_feature = "atomics")`.
-rw-r--r--library/std/src/sys/wasi/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/library/std/src/sys/wasi/mod.rs b/library/std/src/sys/wasi/mod.rs
index 1dc3f2b2026..c468ae395fc 100644
--- a/library/std/src/sys/wasi/mod.rs
+++ b/library/std/src/sys/wasi/mod.rs
@@ -32,8 +32,6 @@ pub mod io;
 #[path = "../unsupported/locks/mod.rs"]
 pub mod locks;
 pub mod net;
-#[path = "../unsupported/once.rs"]
-pub mod once;
 pub mod os;
 #[path = "../unix/os_str.rs"]
 pub mod os_str;
@@ -51,6 +49,13 @@ pub mod thread_local_dtor;
 pub mod thread_local_key;
 pub mod time;
 
+cfg_if::cfg_if! {
+    if #[cfg(not(target_feature = "atomics"))] {
+        #[path = "../unsupported/once.rs"]
+        pub mod once;
+    }
+}
+
 #[path = "../unsupported/common.rs"]
 #[deny(unsafe_op_in_unsafe_fn)]
 #[allow(unused)]