diff --git a/compiler/erg_compiler/main.rs b/compiler/erg_compiler/main.rs index 9242289e..89cae104 100644 --- a/compiler/erg_compiler/main.rs +++ b/compiler/erg_compiler/main.rs @@ -3,6 +3,7 @@ extern crate erg_compiler; extern crate erg_parser; use std::process; +use std::thread; use erg_common::config::ErgConfig; use erg_common::traits::Runnable; @@ -14,7 +15,7 @@ use erg_parser::ParserRunner; use erg_type::deserialize::Deserializer; -fn main() { +fn run() { let cfg = ErgConfig::parse(); match cfg.mode { "lex" => { @@ -35,3 +36,19 @@ fn main() { } } } + +fn main() { + if cfg!(windows) { + const STACK_SIZE: usize = 4 * 1024 * 1024; + + let child = thread::Builder::new() + .stack_size(STACK_SIZE) + .spawn(run) + .unwrap(); + + // Wait for thread to join + child.join().unwrap(); + } else { + run(); + } +} diff --git a/compiler/erg_parser/main.rs b/compiler/erg_parser/main.rs index f214e2b3..a36e8703 100644 --- a/compiler/erg_parser/main.rs +++ b/compiler/erg_parser/main.rs @@ -2,6 +2,7 @@ extern crate erg_common; extern crate erg_parser; use std::process; +use std::thread; use erg_common::config::ErgConfig; use erg_common::traits::Runnable; @@ -9,7 +10,7 @@ use erg_common::traits::Runnable; use erg_parser::lex::LexerRunner; use erg_parser::ParserRunner; -fn main() { +fn run() { let cfg = ErgConfig::parse(); match cfg.mode { "lex" => { @@ -24,3 +25,19 @@ fn main() { } } } + +fn main() { + if cfg!(windows) { + const STACK_SIZE: usize = 4 * 1024 * 1024; + + let child = thread::Builder::new() + .stack_size(STACK_SIZE) + .spawn(run) + .unwrap(); + + // Wait for thread to join + child.join().unwrap(); + } else { + run(); + } +} diff --git a/src/main.rs b/src/main.rs index 8a335ac7..3eba2e58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ extern crate erg_compiler; extern crate erg_parser; use std::process; +use std::thread; use erg_common::config::ErgConfig; use erg_common::traits::Runnable; @@ -16,7 +17,7 @@ use erg_type::deserialize::Deserializer; use erg::dummy::DummyVM; -fn main() { +fn run() { let cfg = ErgConfig::parse(); match cfg.mode { "lex" => { @@ -40,3 +41,19 @@ fn main() { } } } + +fn main() { + if cfg!(windows) { + const STACK_SIZE: usize = 4 * 1024 * 1024; + + let child = thread::Builder::new() + .stack_size(STACK_SIZE) + .spawn(run) + .unwrap(); + + // Wait for thread to join + child.join().unwrap(); + } else { + run(); + } +}