Skip to content

Commit cb98383

Browse files
committed
Auto merge of rust-lang#90382 - alexcrichton:wasm64-libstd, r=joshtriplett
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.
2 parents 7618a40 + 56e00e3 commit cb98383

File tree

15 files changed

+33
-31
lines changed

15 files changed

+33
-31
lines changed

core/src/ffi.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl fmt::Debug for c_void {
6262
#[cfg(any(
6363
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
6464
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
65-
target_arch = "wasm32",
65+
target_family = "wasm",
6666
target_arch = "asmjs",
6767
windows
6868
))]
@@ -85,7 +85,7 @@ pub struct VaListImpl<'f> {
8585
#[cfg(any(
8686
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
8787
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
88-
target_arch = "wasm32",
88+
target_family = "wasm",
8989
target_arch = "asmjs",
9090
windows
9191
))]
@@ -185,7 +185,7 @@ pub struct VaList<'a, 'f: 'a> {
185185
not(target_arch = "x86_64")
186186
),
187187
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
188-
target_arch = "wasm32",
188+
target_family = "wasm",
189189
target_arch = "asmjs",
190190
windows
191191
))]
@@ -194,7 +194,7 @@ pub struct VaList<'a, 'f: 'a> {
194194
#[cfg(all(
195195
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
196196
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
197-
not(target_arch = "wasm32"),
197+
not(target_family = "wasm"),
198198
not(target_arch = "asmjs"),
199199
not(windows)
200200
))]
@@ -206,7 +206,7 @@ pub struct VaList<'a, 'f: 'a> {
206206
#[cfg(any(
207207
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
208208
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
209-
target_arch = "wasm32",
209+
target_family = "wasm",
210210
target_arch = "asmjs",
211211
windows
212212
))]
@@ -227,7 +227,7 @@ impl<'f> VaListImpl<'f> {
227227
#[cfg(all(
228228
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
229229
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
230-
not(target_arch = "wasm32"),
230+
not(target_family = "wasm"),
231231
not(target_arch = "asmjs"),
232232
not(windows)
233233
))]

panic_abort/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMe
117117
pub mod personalities {
118118
#[rustc_std_internal_symbol]
119119
#[cfg(not(any(
120-
all(target_arch = "wasm32", not(target_os = "emscripten"),),
120+
all(target_family = "wasm", not(target_os = "emscripten")),
121121
all(target_os = "windows", target_env = "gnu", target_arch = "x86_64",),
122122
)))]
123123
pub extern "C" fn rust_eh_personality() {}

panic_unwind/src/dummy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! Unwinding for *wasm32* target.
1+
//! Unwinding for unsupported target.
22
//!
3-
//! Right now we don't support this, so this is just stubs.
3+
//! Stubs that simply abort for targets that don't support unwinding otherwise.
44
55
use alloc::boxed::Box;
66
use core::any::Any;

panic_unwind/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ cfg_if::cfg_if! {
5656
mod real_imp;
5757
} else {
5858
// Targets that don't support unwinding.
59-
// - arch=wasm32
59+
// - family=wasm
6060
// - os=none ("bare metal" targets)
6161
// - os=uefi
6262
// - os=espidf

std/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
1616
panic_abort = { path = "../panic_abort" }
1717
core = { path = "../core" }
1818
libc = { version = "0.2.106", default-features = false, features = ['rustc-dep-of-std'] }
19-
compiler_builtins = { version = "0.1.44" }
19+
compiler_builtins = { version = "0.1.52" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }
2222
hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }
@@ -35,8 +35,8 @@ features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive']
3535
[dev-dependencies]
3636
rand = "0.7"
3737

38-
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
39-
dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] }
38+
[target.'cfg(any(all(target_family = "wasm", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
39+
dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
4040

4141
[target.x86_64-fortanix-unknown-sgx.dependencies]
4242
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }

std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn main() {
2525
|| target.contains("haiku")
2626
|| target.contains("vxworks")
2727
|| target.contains("wasm32")
28+
|| target.contains("wasm64")
2829
|| target.contains("asmjs")
2930
|| target.contains("espidf")
3031
|| target.contains("solid")

std/src/sys/common/alloc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub const MIN_ALIGN: usize = 8;
2424
target_arch = "mips64",
2525
target_arch = "s390x",
2626
target_arch = "sparc64",
27-
target_arch = "riscv64"
27+
target_arch = "riscv64",
28+
target_arch = "wasm64",
2829
)))]
2930
pub const MIN_ALIGN: usize = 16;
3031

std/src/sys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cfg_if::cfg_if! {
4040
} else if #[cfg(target_os = "wasi")] {
4141
mod wasi;
4242
pub use self::wasi::*;
43-
} else if #[cfg(target_arch = "wasm32")] {
43+
} else if #[cfg(target_family = "wasm")] {
4444
mod wasm;
4545
pub use self::wasm::*;
4646
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {

std/src/sys/wasm/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//! This is an implementation of a global allocator on the wasm32 platform when
1+
//! This is an implementation of a global allocator on wasm targets when
22
//! emscripten is not in use. In that situation there's no actual runtime for us
33
//! to lean on for allocation, so instead we provide our own!
44
//!
5-
//! The wasm32 instruction set has two instructions for getting the current
5+
//! The wasm instruction set has two instructions for getting the current
66
//! amount of memory and growing the amount of memory. These instructions are the
77
//! foundation on which we're able to build an allocator, so we do so! Note that
88
//! the instructions are also pretty "global" and this is the "global" allocator

std/src/sys_common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cfg_if::cfg_if! {
4040
if #[cfg(any(target_os = "l4re",
4141
target_os = "hermit",
4242
feature = "restricted-std",
43-
all(target_arch = "wasm32", not(target_os = "emscripten")),
43+
all(target_family = "wasm", not(target_os = "emscripten")),
4444
all(target_vendor = "fortanix", target_env = "sgx")))] {
4545
pub use crate::sys::net;
4646
} else {

0 commit comments

Comments
 (0)