Skip to content

Commit 42d39a0

Browse files
committed
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.
1 parent b67628e commit 42d39a0

File tree

12 files changed

+37
-17
lines changed

12 files changed

+37
-17
lines changed

core/src/ffi.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl fmt::Debug for c_void {
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")),
6565
target_arch = "wasm32",
66+
target_arch = "wasm64",
6667
target_arch = "asmjs",
6768
windows
6869
))]
@@ -86,6 +87,7 @@ pub struct VaListImpl<'f> {
8687
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
8788
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
8889
target_arch = "wasm32",
90+
target_arch = "wasm64",
8991
target_arch = "asmjs",
9092
windows
9193
))]
@@ -186,6 +188,7 @@ pub struct VaList<'a, 'f: 'a> {
186188
),
187189
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
188190
target_arch = "wasm32",
191+
target_arch = "wasm64",
189192
target_arch = "asmjs",
190193
windows
191194
))]
@@ -195,6 +198,7 @@ pub struct VaList<'a, 'f: 'a> {
195198
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
196199
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
197200
not(target_arch = "wasm32"),
201+
not(target_arch = "wasm64"),
198202
not(target_arch = "asmjs"),
199203
not(windows)
200204
))]
@@ -207,6 +211,7 @@ pub struct VaList<'a, 'f: 'a> {
207211
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
208212
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
209213
target_arch = "wasm32",
214+
target_arch = "wasm64",
210215
target_arch = "asmjs",
211216
windows
212217
))]
@@ -228,6 +233,7 @@ impl<'f> VaListImpl<'f> {
228233
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
229234
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
230235
not(target_arch = "wasm32"),
236+
not(target_arch = "wasm64"),
231237
not(target_arch = "asmjs"),
232238
not(windows)
233239
))]

panic_abort/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ 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_arch = "wasm32", not(target_os = "emscripten")),
121+
all(target_arch = "wasm64", not(target_os = "emscripten")),
121122
all(target_os = "windows", target_env = "gnu", target_arch = "x86_64",),
122123
)))]
123124
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ cfg_if::cfg_if! {
5757
} else {
5858
// Targets that don't support unwinding.
5959
// - arch=wasm32
60+
// - arch=wasm64
6061
// - os=none ("bare metal" targets)
6162
// - os=uefi
6263
// - os=espidf

std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ 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]
38+
[target.'cfg(any(all(any(target_arch = "wasm32", target_arch = "wasm64"), not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
3939
dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] }
4040

4141
[target.x86_64-fortanix-unknown-sgx.dependencies]

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(any(target_arch = "wasm32", target_arch = "wasm64"))] {
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 the wasm platform 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cfg_if::cfg_if! {
4141
target_os = "hermit",
4242
feature = "restricted-std",
4343
all(target_arch = "wasm32", not(target_os = "emscripten")),
44+
all(target_arch = "wasm64", not(target_os = "emscripten")),
4445
all(target_vendor = "fortanix", target_env = "sgx")))] {
4546
pub use crate::sys::net;
4647
} else {

0 commit comments

Comments
 (0)