about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-04-20 23:45:41 +0800
committerGitHub <noreply@github.com>2018-04-20 23:45:41 +0800
commitfff68f761ed7cedcb2941a204f4701877ae7fcfd (patch)
treef5f3ab9f6c4beefa69e94a0d0f7c8b73b1a9ebc1 /src
parentaa078e1c9c1bd6feccac9da644f563e3625b2bbc (diff)
parente58629b990ee8ca2dc8fde0703fc7ca2b4b2a809 (diff)
Rollup merge of #50083 - alexcrichton:increase-wasm-stack, r=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.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/back/linker.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustc_trans/back/linker.rs b/src/librustc_trans/back/linker.rs
index ebcf06d63be..e001e809ee5 100644
--- a/src/librustc_trans/back/linker.rs
+++ b/src/librustc_trans/back/linker.rs
@@ -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