# MSVC-only: bump the default 1 MB Windows stack to 8 MB. clap-derive builds # a large Command enum in this CLI (one variant per subcommand, each carrying # flag args); in debug builds the enum is materialized on the stack without # optimization and overflows the default Windows main-thread stack before # even reaching our code. # # The /STACK: link-arg goes into the PE header's IMAGE_OPTIONAL_HEADER. # SizeOfStackReserve at link time and applies to both debug and release # builds — release artifacts ship with the same 8 MB stack reservation. At # runtime the optimizer elides the enum from the stack frame, so release # builds would not overflow without this setting; it is kept on for them so # both build flavours produce binaries with identical stack metadata. # # `/STACK:` is an MSVC-linker (`link.exe` / `lld-link`) directive. The # `target_env = "msvc"` selector below scopes the rustflag to the MSVC # toolchain so `x86_64-pc-windows-gnu` (mingw) builds, which route link # args through the GNU linker and reject `/STACK:`, are unaffected. [target.'cfg(all(windows, target_env = "msvc"))'] rustflags = ["-C", "link-arg=/STACK:8388608"]