On Windows an area of virtual memory is reserved for the main thread's stack to grow in to. The size of this area is requested by the application via the binary's header. Currently Rust does not set the size of this reserved area so instead the linker uses a fallback value (often only 1 MiB).
I think Rust should set the maximum stack size to at least match the default size for new threads (if not larger). This can be done via linker flags. E.g. reserving 16 MiB of virtual memory for stack space is done using /STACK argument on MSVC:
/STACK:16777216
And on Mingw it's --stack:
-Wl,--stack,16777216
However, if Rust does set the stack size it would need a way to override this value. Perhaps via a -C codegen option?
On Windows an area of virtual memory is reserved for the main thread's stack to grow in to. The size of this area is requested by the application via the binary's header. Currently Rust does not set the size of this reserved area so instead the linker uses a fallback value (often only 1 MiB).
I think Rust should set the maximum stack size to at least match the default size for new threads (if not larger). This can be done via linker flags. E.g. reserving 16 MiB of virtual memory for stack space is done using
/STACKargument on MSVC:/STACK:16777216And on Mingw it's
--stack:-Wl,--stack,16777216However, if Rust does set the stack size it would need a way to override this value. Perhaps via a
-Ccodegen option?