@@ -11,6 +11,8 @@ use chialisp::classic::platform::argparse::ArgumentValue;
1111use chialisp:: compiler:: comptypes:: CompileErr ;
1212use chialisp:: compiler:: srcloc:: Srcloc ;
1313
14+ const CHIALISP_COMPILER_STACK_SIZE : usize = 128 * 1024 * 1024 ;
15+
1416fn 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+
7492fn 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