diff --git a/.cargo/config.toml b/.cargo/config.toml index 635229119f8..b307d35eee9 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -6,3 +6,15 @@ rustflags = "-C link-args=-Wl,--stack,8000000" [target.wasm32-unknown-unknown] rustflags = ["--cfg=getrandom_backend=\"wasm_js\""] + +[target.wasm32-wasip1] +rustflags = [ + "-C", "link-arg=--max-memory=67108864", + "-C", "link-arg=-zstack-size=1048576", +] + +[target.wasm32-wasip2] +rustflags = [ + "-C", "link-arg=--max-memory=67108864", + "-C", "link-arg=-zstack-size=1048576", +] diff --git a/Cargo.toml b/Cargo.toml index 7bd8b8f3374..b7469da89bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,6 +100,14 @@ opt-level = 3 [profile.release] lto = "thin" +[profile.wasm-release] +inherits = "release" +opt-level = "s" +lto = true +codegen-units = 1 +strip = true +panic = "abort" + [patch.crates-io] parking_lot_core = { git = "https://github.com/youknowone/parking_lot", branch = "rustpython" } # REDOX START, Uncomment when you want to compile/check with redoxer diff --git a/crates/vm/src/datastack.rs b/crates/vm/src/datastack.rs index b00f1b6dc19..370f4197e91 100644 --- a/crates/vm/src/datastack.rs +++ b/crates/vm/src/datastack.rs @@ -9,6 +9,10 @@ use core::alloc::Layout; use core::ptr; /// Minimum chunk size in bytes (`_PY_DATA_STACK_CHUNK_SIZE`). +/// Smaller on WASM to reduce initial memory footprint. +#[cfg(target_arch = "wasm32")] +const MIN_CHUNK_SIZE: usize = 4 * 1024; +#[cfg(not(target_arch = "wasm32"))] const MIN_CHUNK_SIZE: usize = 16 * 1024; /// Extra headroom (in bytes) to avoid allocating a new chunk for the next