Skip to content

Commit

Permalink
Rollup merge of rust-lang#50083 - alexcrichton:increase-wasm-stack, r…
Browse files Browse the repository at this point in the history
…=michaelwoerister

wasm: Increase default stack size to 1MB

This commit increases the dfeault stack size allocated to the
wasm32-unknown-unknown target to 1MB by default. Currently the default stack
size is one wasm page, or 64 kilobytes. This default stack is quite small and
has caused a stack overflow or two in the wild by accident.

The current "best practice" for fixing this is to pass `-Clink-args='-z
stack-size=$bigger'` but that's not great nor always easy to do. A default of
1MB matches more closely with other platforms where it's "pretty big" by
default.

Note that it was tested and if the users uses `-C link-args` to pass a custom
stack size that's still resepected as lld seems to take the first argument, and
where rustc is passing it will always be last.
  • Loading branch information
kennytm authored Apr 20, 2018
2 parents aa078e1 + e58629b commit fff68f7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_trans/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ impl Linker for WasmLd {

fn finalize(&mut self) -> Command {
self.cmd.arg("--threads");
self.cmd.arg("-z").arg("stack-size=1048576");

// FIXME we probably shouldn't pass this but instead pass an explicit
// whitelist of symbols we'll allow to be undefined. Unfortunately
Expand Down

0 comments on commit fff68f7

Please sign in to comment.