Skip to content

Commit 05b2d3f

Browse files
committed
std: Enable atomic.fence emission on wasm32
This commit removes the `#[cfg]` guards in `atomic::fence` on wasm targets. Since these guards were originally added the upstream wasm specification for threads gained an `atomic.fence` instruction, so LLVM no longer panics on these intrinsics. Although there aren't a ton of tests in-repo for this right now I've tested locally and all of these fences generate `atomic.fence` instructions in wasm. Closes #72997
1 parent 219380d commit 05b2d3f

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

src/libcore/sync/atomic.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2536,15 +2536,7 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
25362536
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
25372537
#[inline]
25382538
#[stable(feature = "rust1", since = "1.0.0")]
2539-
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
25402539
pub fn fence(order: Ordering) {
2541-
// On wasm32 it looks like fences aren't implemented in LLVM yet in that
2542-
// they will cause LLVM to abort. The wasm instruction set doesn't have
2543-
// fences right now. There's discussion online about the best way for tools
2544-
// to conventionally implement fences at
2545-
// https://github.com/WebAssembly/tool-conventions/issues/59. We should
2546-
// follow that discussion and implement a solution when one comes about!
2547-
#[cfg(not(target_arch = "wasm32"))]
25482540
// SAFETY: using an atomic fence is safe.
25492541
unsafe {
25502542
match order {

0 commit comments

Comments
 (0)