From 0ebef5a1a73c2fa342ae4ceb41560154ce268c56 Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 10:58:16 -0700 Subject: [PATCH 1/6] std: Get the standard library compiling for wasm64 This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged. --- .../src/spec/wasm64_unknown_unknown.rs | 9 ++++---- library/core/src/ffi.rs | 6 +++++ library/panic_abort/src/lib.rs | 3 ++- library/panic_unwind/src/dummy.rs | 4 ++-- library/panic_unwind/src/lib.rs | 1 + library/std/Cargo.toml | 2 +- library/std/build.rs | 1 + library/std/src/sys/common/alloc.rs | 3 ++- library/std/src/sys/mod.rs | 2 +- library/std/src/sys/wasm/alloc.rs | 4 ++-- library/std/src/sys_common/mod.rs | 1 + library/std/src/thread/local.rs | 22 ++++++++++++------- library/std/src/thread/mod.rs | 5 ++++- 13 files changed, 41 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs index fb6526c0e7203..7eacbb4364026 100644 --- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs @@ -23,11 +23,10 @@ pub fn target() -> Target { // For now this target just never has an entry symbol no matter the output // type, so unconditionally pass this. clang_args.push("-Wl,--no-entry".to_string()); - options - .pre_link_args - .get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)) - .unwrap() - .push("--no-entry".to_string()); + + let lld_args = options.pre_link_args.get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm)).unwrap(); + lld_args.push("--no-entry".to_string()); + lld_args.push("-mwasm64".to_string()); Target { llvm_target: "wasm64-unknown-unknown".to_string(), diff --git a/library/core/src/ffi.rs b/library/core/src/ffi.rs index b208ddd4b272f..ea3de680afeda 100644 --- a/library/core/src/ffi.rs +++ b/library/core/src/ffi.rs @@ -63,6 +63,7 @@ impl fmt::Debug for c_void { all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), target_arch = "wasm32", + target_arch = "wasm64", target_arch = "asmjs", windows ))] @@ -86,6 +87,7 @@ pub struct VaListImpl<'f> { all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), target_arch = "wasm32", + target_arch = "wasm64", target_arch = "asmjs", windows ))] @@ -186,6 +188,7 @@ pub struct VaList<'a, 'f: 'a> { ), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), target_arch = "wasm32", + target_arch = "wasm64", target_arch = "asmjs", windows ))] @@ -195,6 +198,7 @@ pub struct VaList<'a, 'f: 'a> { any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))), not(target_arch = "wasm32"), + not(target_arch = "wasm64"), not(target_arch = "asmjs"), not(windows) ))] @@ -207,6 +211,7 @@ pub struct VaList<'a, 'f: 'a> { all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), target_arch = "wasm32", + target_arch = "wasm64", target_arch = "asmjs", windows ))] @@ -228,6 +233,7 @@ impl<'f> VaListImpl<'f> { any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))), not(target_arch = "wasm32"), + not(target_arch = "wasm64"), not(target_arch = "asmjs"), not(windows) ))] diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index ac75ce7f22110..d31df0da36435 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -117,7 +117,8 @@ pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMe pub mod personalities { #[rustc_std_internal_symbol] #[cfg(not(any( - all(target_arch = "wasm32", not(target_os = "emscripten"),), + all(target_arch = "wasm32", not(target_os = "emscripten")), + all(target_arch = "wasm64", not(target_os = "emscripten")), all(target_os = "windows", target_env = "gnu", target_arch = "x86_64",), )))] pub extern "C" fn rust_eh_personality() {} diff --git a/library/panic_unwind/src/dummy.rs b/library/panic_unwind/src/dummy.rs index 4667ede2baad5..a4bcd216c60f0 100644 --- a/library/panic_unwind/src/dummy.rs +++ b/library/panic_unwind/src/dummy.rs @@ -1,6 +1,6 @@ -//! Unwinding for *wasm32* target. +//! Unwinding for unsupported target. //! -//! Right now we don't support this, so this is just stubs. +//! Stubs that simply abort for targets that don't support unwinding otherwise. use alloc::boxed::Box; use core::any::Any; diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index b5d0ca2572c93..4815249f7d53e 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -57,6 +57,7 @@ cfg_if::cfg_if! { } else { // Targets that don't support unwinding. // - arch=wasm32 + // - arch=wasm64 // - os=none ("bare metal" targets) // - os=uefi // - os=espidf diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 6bc445c6f2b07..6ac739fdc4d3d 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -35,7 +35,7 @@ features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] [dev-dependencies] rand = "0.7" -[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] +[target.'cfg(any(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] } [target.x86_64-fortanix-unknown-sgx.dependencies] diff --git a/library/std/build.rs b/library/std/build.rs index cc7184d57f178..43168e77296ab 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -25,6 +25,7 @@ fn main() { || target.contains("haiku") || target.contains("vxworks") || target.contains("wasm32") + || target.contains("wasm64") || target.contains("asmjs") || target.contains("espidf") || target.contains("solid") diff --git a/library/std/src/sys/common/alloc.rs b/library/std/src/sys/common/alloc.rs index 576667c017392..9665d1fa89243 100644 --- a/library/std/src/sys/common/alloc.rs +++ b/library/std/src/sys/common/alloc.rs @@ -24,7 +24,8 @@ pub const MIN_ALIGN: usize = 8; target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", - target_arch = "riscv64" + target_arch = "riscv64", + target_arch = "wasm64", )))] pub const MIN_ALIGN: usize = 16; diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 8b8be6ebc2f55..38f45fef9180f 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -40,7 +40,7 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "wasi")] { mod wasi; pub use self::wasi::*; - } else if #[cfg(target_arch = "wasm32")] { + } else if #[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))] { mod wasm; pub use self::wasm::*; } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { diff --git a/library/std/src/sys/wasm/alloc.rs b/library/std/src/sys/wasm/alloc.rs index ef0ca3dd478cc..bf5dc0273c075 100644 --- a/library/std/src/sys/wasm/alloc.rs +++ b/library/std/src/sys/wasm/alloc.rs @@ -1,8 +1,8 @@ -//! This is an implementation of a global allocator on the wasm32 platform when +//! This is an implementation of a global allocator on the wasm platform when //! emscripten is not in use. In that situation there's no actual runtime for us //! to lean on for allocation, so instead we provide our own! //! -//! The wasm32 instruction set has two instructions for getting the current +//! The wasm instruction set has two instructions for getting the current //! amount of memory and growing the amount of memory. These instructions are the //! foundation on which we're able to build an allocator, so we do so! Note that //! the instructions are also pretty "global" and this is the "global" allocator diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 5a5913ebd79a3..0f2a8cd001259 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -41,6 +41,7 @@ cfg_if::cfg_if! { target_os = "hermit", feature = "restricted-std", all(target_arch = "wasm32", not(target_os = "emscripten")), + all(target_arch = "wasm64", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))] { pub use crate::sys::net; } else { diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index c53290ec0c7d0..37f9cc40be62f 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -172,7 +172,7 @@ macro_rules! __thread_local_inner { // // FIXME(#84224) this should come after the `target_thread_local` // block. - #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] { static mut VAL: $t = $init; Some(&VAL) @@ -181,7 +181,10 @@ macro_rules! __thread_local_inner { // If the platform has support for `#[thread_local]`, use it. #[cfg(all( target_thread_local, - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all( + any(target_arch = "wasm32", target_arch = "wasm64"), + not(target_feature = "atomics"), + )), ))] { // If a dtor isn't needed we can do something "very raw" and @@ -238,7 +241,10 @@ macro_rules! __thread_local_inner { // same implementation as below for os thread locals. #[cfg(all( not(target_thread_local), - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all( + any(target_arch = "wasm32", target_arch = "wasm64"), + not(target_feature = "atomics"), + )), ))] { #[inline] @@ -285,21 +291,21 @@ macro_rules! __thread_local_inner { // The issue of "should enable on Windows sometimes" is #84933 #[cfg_attr(not(windows), inline)] unsafe fn __getit() -> $crate::option::Option<&'static $t> { - #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = $crate::thread::__StaticLocalKeyInner::new(); #[thread_local] #[cfg(all( target_thread_local, - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__FastLocalKeyInner<$t> = $crate::thread::__FastLocalKeyInner::new(); #[cfg(all( not(target_thread_local), - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); @@ -479,10 +485,10 @@ mod lazy { } } -/// On some platforms like wasm32 there's no threads, so no need to generate +/// On some platforms like wasm there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] +#[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] pub mod statik { use super::lazy::LazyKeyInner; use crate::fmt; diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 1a5cf5ab8226a..841d9e58f9a4a 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -200,7 +200,10 @@ pub use self::local::fast::Key as __FastLocalKeyInner; #[doc(hidden)] pub use self::local::os::Key as __OsLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "none")] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] +#[cfg(all( + any(target_arch = "wasm32", target_arch = "wasm64"), + not(target_feature = "atomics") +))] #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; From 9d339c21856d845b5940e56af11a3e545879f0e8 Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 11:20:46 -0700 Subject: [PATCH 2/6] Enable WebAssembly features by default on wasm64 These are all stable as-of-now in the WebAssembly specification so any engine which implements wasm64 will surely implement these features as well. --- compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs index 7eacbb4364026..6b7dfbb87d250 100644 --- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs @@ -28,6 +28,11 @@ pub fn target() -> Target { lld_args.push("--no-entry".to_string()); lld_args.push("-mwasm64".to_string()); + // Any engine that implements wasm64 will surely implement the rest of these + // features since they were all merged into the official spec by the time + // wasm64 was designed. + options.features = "+bulk-memory,+mutable-globals,+sign-ext,+nontrapping-fptoint".to_string(); + Target { llvm_target: "wasm64-unknown-unknown".to_string(), pointer_width: 64, From cdfafca0a97e3225ef4c0fd1357e83a82849cd82 Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 16:28:21 -0700 Subject: [PATCH 3/6] Use `target_family = "wasm"` --- library/core/src/ffi.rs | 18 ++++++------------ library/panic_abort/src/lib.rs | 3 +-- library/std/Cargo.toml | 2 +- library/std/src/sys/mod.rs | 2 +- library/std/src/sys_common/mod.rs | 3 +-- library/std/src/thread/local.rs | 20 +++++++------------- library/std/src/thread/mod.rs | 5 +---- 7 files changed, 18 insertions(+), 35 deletions(-) diff --git a/library/core/src/ffi.rs b/library/core/src/ffi.rs index ea3de680afeda..9c4cf89b6bc35 100644 --- a/library/core/src/ffi.rs +++ b/library/core/src/ffi.rs @@ -62,8 +62,7 @@ impl fmt::Debug for c_void { #[cfg(any( all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), - target_arch = "wasm32", - target_arch = "wasm64", + target_family = "wasm", target_arch = "asmjs", windows ))] @@ -86,8 +85,7 @@ pub struct VaListImpl<'f> { #[cfg(any( all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), - target_arch = "wasm32", - target_arch = "wasm64", + target_family = "wasm", target_arch = "asmjs", windows ))] @@ -187,8 +185,7 @@ pub struct VaList<'a, 'f: 'a> { not(target_arch = "x86_64") ), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), - target_arch = "wasm32", - target_arch = "wasm64", + target_family = "wasm", target_arch = "asmjs", windows ))] @@ -197,8 +194,7 @@ pub struct VaList<'a, 'f: 'a> { #[cfg(all( any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))), - not(target_arch = "wasm32"), - not(target_arch = "wasm64"), + not(target_family = "wasm"), not(target_arch = "asmjs"), not(windows) ))] @@ -210,8 +206,7 @@ pub struct VaList<'a, 'f: 'a> { #[cfg(any( all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")), all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")), - target_arch = "wasm32", - target_arch = "wasm64", + target_family = "wasm", target_arch = "asmjs", windows ))] @@ -232,8 +227,7 @@ impl<'f> VaListImpl<'f> { #[cfg(all( any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))), - not(target_arch = "wasm32"), - not(target_arch = "wasm64"), + not(target_family = "wasm"), not(target_arch = "asmjs"), not(windows) ))] diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index d31df0da36435..dec5e0b2123fc 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -117,8 +117,7 @@ pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMe pub mod personalities { #[rustc_std_internal_symbol] #[cfg(not(any( - all(target_arch = "wasm32", not(target_os = "emscripten")), - all(target_arch = "wasm64", not(target_os = "emscripten")), + all(target_family = "wasm", not(target_os = "emscripten")), all(target_os = "windows", target_env = "gnu", target_arch = "x86_64",), )))] pub extern "C" fn rust_eh_personality() {} diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 6ac739fdc4d3d..653be07b20210 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -35,7 +35,7 @@ features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] [dev-dependencies] rand = "0.7" -[target.'cfg(any(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] +[target.'cfg(any(all(target_family = "wasm", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] } [target.x86_64-fortanix-unknown-sgx.dependencies] diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 38f45fef9180f..167c918c94cf9 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -40,7 +40,7 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "wasi")] { mod wasi; pub use self::wasi::*; - } else if #[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))] { + } else if #[cfg(target_family = "wasm")] { mod wasm; pub use self::wasm::*; } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 0f2a8cd001259..804727fbc54d1 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -40,8 +40,7 @@ cfg_if::cfg_if! { if #[cfg(any(target_os = "l4re", target_os = "hermit", feature = "restricted-std", - all(target_arch = "wasm32", not(target_os = "emscripten")), - all(target_arch = "wasm64", not(target_os = "emscripten")), + all(target_family = "wasm", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))] { pub use crate::sys::net; } else { diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 37f9cc40be62f..da297c9201746 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -172,7 +172,7 @@ macro_rules! __thread_local_inner { // // FIXME(#84224) this should come after the `target_thread_local` // block. - #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] + #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] { static mut VAL: $t = $init; Some(&VAL) @@ -181,10 +181,7 @@ macro_rules! __thread_local_inner { // If the platform has support for `#[thread_local]`, use it. #[cfg(all( target_thread_local, - not(all( - any(target_arch = "wasm32", target_arch = "wasm64"), - not(target_feature = "atomics"), - )), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] { // If a dtor isn't needed we can do something "very raw" and @@ -241,10 +238,7 @@ macro_rules! __thread_local_inner { // same implementation as below for os thread locals. #[cfg(all( not(target_thread_local), - not(all( - any(target_arch = "wasm32", target_arch = "wasm64"), - not(target_feature = "atomics"), - )), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] { #[inline] @@ -291,21 +285,21 @@ macro_rules! __thread_local_inner { // The issue of "should enable on Windows sometimes" is #84933 #[cfg_attr(not(windows), inline)] unsafe fn __getit() -> $crate::option::Option<&'static $t> { - #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] + #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = $crate::thread::__StaticLocalKeyInner::new(); #[thread_local] #[cfg(all( target_thread_local, - not(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__FastLocalKeyInner<$t> = $crate::thread::__FastLocalKeyInner::new(); #[cfg(all( not(target_thread_local), - not(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); @@ -488,7 +482,7 @@ mod lazy { /// On some platforms like wasm there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_feature = "atomics")))] +#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] pub mod statik { use super::lazy::LazyKeyInner; use crate::fmt; diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 841d9e58f9a4a..e8f906c33bea7 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -200,10 +200,7 @@ pub use self::local::fast::Key as __FastLocalKeyInner; #[doc(hidden)] pub use self::local::os::Key as __OsLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "none")] -#[cfg(all( - any(target_arch = "wasm32", target_arch = "wasm64"), - not(target_feature = "atomics") -))] +#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; From 5b25663ff3d1cafddd0fede0f7c9a6e1ef935a92 Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 16:29:23 -0700 Subject: [PATCH 4/6] Update platform support docs --- src/doc/rustc/src/platform-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index bbeab598f2292..bc7f3ec9ede18 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -276,7 +276,7 @@ target | std | host | notes `thumbv7a-pc-windows-msvc` | ? | | `thumbv7a-uwp-windows-msvc` | ✓ | | `thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7a Linux with NEON, MUSL -`wasm64-unknown-unknown` | * | | WebAssembly +`wasm64-unknown-unknown` | ? | | WebAssembly `x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64 `x86_64-apple-tvos` | * | | x86 64-bit tvOS `x86_64-pc-windows-msvc` | ✓ | | 64-bit Windows XP support From c8a412af5a7ae4d8b8d29803717c5363a1fd1d85 Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 16:36:05 -0700 Subject: [PATCH 5/6] Update other deps --- .gitmodules | 2 +- Cargo.lock | 5 ++--- Cargo.toml | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index c60a0dd2c7c43..d91c90ca8d199 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,7 +24,7 @@ url = https://github.com/rust-lang/rust-by-example.git [submodule "library/stdarch"] path = library/stdarch - url = https://github.com/rust-lang/stdarch.git + url = https://github.com/alexcrichton/stdarch.git [submodule "src/doc/rustc-dev-guide"] path = src/doc/rustc-dev-guide url = https://github.com/rust-lang/rustc-dev-guide.git diff --git a/Cargo.lock b/Cargo.lock index bf19f5e0ae32f..2ba1c3702b350 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -678,9 +678,8 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20b1438ef42c655665a8ab2c1c6d605a305f031d38d9be689ddfef41a20f3aa2" +version = "0.1.51" +source = "git+https://github.com/alexcrichton/compiler-builtins?branch=wasm64-updates#cb06f58efcf484132977bac8f1075bd3d5a9ac38" dependencies = [ "cc", "rustc-std-workspace-core", diff --git a/Cargo.toml b/Cargo.toml index cae48d7951783..9ca51cb1dec58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,5 +131,7 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } +compiler_builtins = { git = 'https://github.com/alexcrichton/compiler-builtins', branch = 'wasm64-updates' } + [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } From 89db2fc500467b8d4702ca5de3765653e49c24cd Mon Sep 17 00:00:00 2001 From: Alex Crichton <alex@alexcrichton.com> Date: Thu, 28 Oct 2021 16:37:32 -0700 Subject: [PATCH 6/6] update-llvm --- .gitmodules | 2 +- compiler/rustc_llvm/build.rs | 2 +- compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs | 2 +- src/bootstrap/compile.rs | 2 +- src/llvm-project | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index d91c90ca8d199..2f3d92402a5af 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ url = https://github.com/rust-lang/edition-guide.git [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git + url = https://github.com/llvm/llvm-project.git branch = rustc/13.0-2021-09-30 [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 36a6d2cc33a99..7aac540194797 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -151,7 +151,7 @@ fn main() { cfg.define(&flag, None); } - if tracked_env_var_os("LLVM_RUSTLLVM").is_some() { + if false && tracked_env_var_os("LLVM_RUSTLLVM").is_some() { cfg.define("LLVM_RUSTLLVM", None); } diff --git a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs index 6b7dfbb87d250..d786f752a5d55 100644 --- a/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs @@ -36,7 +36,7 @@ pub fn target() -> Target { Target { llvm_target: "wasm64-unknown-unknown".to_string(), pointer_width: 64, - data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20".to_string(), + data_layout: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(), arch: "wasm64".to_string(), options, } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index e9cc7662e6397..a8c91963f3806 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -338,7 +338,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car // But we don't bother for the stage 0 compiler because it's never used // with LTO. if stage >= 1 { - cargo.rustflag("-Cembed-bitcode=yes"); + // cargo.rustflag("-Cembed-bitcode=yes"); } // By default, rustc does not include unwind tables unless they are required diff --git a/src/llvm-project b/src/llvm-project index a7348ae0df3c7..50bfc451096f1 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit a7348ae0df3c71581dbe3d355fc0fb6ce6332dd0 +Subproject commit 50bfc451096f106aeb7fb9b805235ec44718ddf4