From d189cab027bee94f4a4ef09484e30354c9843764 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Mar 2019 09:12:06 +0100 Subject: [PATCH] Use fallback on emscripten targets --- src/libcore/hint.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs index e73a1a2879347..856720bd55427 100644 --- a/src/libcore/hint.rs +++ b/src/libcore/hint.rs @@ -99,13 +99,29 @@ pub fn spin_loop() { /// This function is a no-op, and does not even read from `dummy`. #[unstable(feature = "test", issue = "27812")] pub fn black_box(dummy: T) -> T { - #[cfg(not(target_arch = "asmjs"))] { + #[cfg(not( + any( + target_arch = "asmjs", + all( + target_arch = "wasm32", + target_os = "emscripten" + ) + ) + ))] { // we need to "use" the argument in some way LLVM can't // introspect. unsafe { asm!("" : : "r"(&dummy)) } dummy } - #[cfg(target_arch = "asmjs")] { + #[cfg( + any( + target_arch = "asmjs", + all( + target_arch = "wasm32", + target_os = "emscripten" + ) + ) + )] { unsafe { let ret = crate::ptr::read_volatile(&dummy); crate::mem::forget(dummy);