desktop/web: Increase stack size on Windows and wasm

This works around a stack overflow with Bloonts Tower Defense 5,
where we have over 400 stack frames at once due to deep
`construct_frame` recursion in `goto` execution.
This commit is contained in:
Aaron Hill 2023-05-30 23:47:14 -05:00
parent 59b219cda6
commit 66f3198f50
2 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,14 @@ fn main() -> Result<(), Box<dyn Error>> {
}
println!("cargo:rustc-env=CFG_RELEASE_CHANNEL={channel}");
// Some SWFS have a large amount of recursion (particularly
// around `goto`s). Increase the stack size on Windows
// accommodate this (the default on Linux is high enough). We
// do the same thing for wasm in web/build.rs.
if std::env::var("TARGET").unwrap().contains("windows") {
println!("cargo:rustc-link-arg=/STACK:4000000");
}
Ok(())
}

7
web/build.rs Normal file
View File

@ -0,0 +1,7 @@
fn main() {
// See 'desktop/build.rs' for more information.
if std::env::var("TARGET").unwrap().contains("wasm") {
println!("cargo:rustc-link-arg=-z");
println!("cargo:rustc-link-arg=stack-size=2000000");
}
}