Skip to content

Commit cce9711

Browse files
committed
use explicit 128 MiB stack
1 parent 85ce0a7 commit cce9711

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

build.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use chialisp::classic::platform::argparse::ArgumentValue;
1111
use chialisp::compiler::comptypes::CompileErr;
1212
use chialisp::compiler::srcloc::Srcloc;
1313

14+
const CHIALISP_COMPILER_STACK_SIZE: usize = 128 * 1024 * 1024;
15+
1416
fn do_compile(title: &str, filename: &str) -> Result<(), CompileError> {
1517
let mut allocator = Allocator::new();
1618
let mut arguments: HashMap<String, ArgumentValue> = HashMap::new();
@@ -71,6 +73,22 @@ fn compile_chialisp() -> Result<(), CompileError> {
7173
Ok(())
7274
}
7375

76+
fn compile_chialisp_with_large_stack() {
77+
let compiler = std::thread::Builder::new()
78+
.name("chialisp-compiler".to_string())
79+
.stack_size(CHIALISP_COMPILER_STACK_SIZE)
80+
.spawn(|| {
81+
if let Err(e) = compile_chialisp() {
82+
panic!("error compiling chialisp: {e:?}");
83+
}
84+
})
85+
.expect("failed to start Chialisp compiler thread");
86+
87+
if let Err(payload) = compiler.join() {
88+
std::panic::resume_unwind(payload);
89+
}
90+
}
91+
7492
fn emit_rerun_directives(dir: &Path) {
7593
if let Ok(entries) = fs::read_dir(dir) {
7694
for entry in entries.flatten() {
@@ -92,8 +110,6 @@ fn main() {
92110
println!("cargo:rerun-if-env-changed=CHIALISP_COMPILE");
93111

94112
if std::env::var("CHIALISP_COMPILE").is_ok() {
95-
if let Err(e) = compile_chialisp() {
96-
panic!("error compiling chialisp: {e:?}");
97-
}
113+
compile_chialisp_with_large_stack();
98114
}
99115
}

0 commit comments

Comments
 (0)