From f1501ff4ea72e5a40bd5cb0819996e9c88aba139 Mon Sep 17 00:00:00 2001 From: nishad shabbir <238154712+Nishuuzz@users.noreply.github.com> Date: Tue, 11 Aug 2026 16:03:10 +0530 Subject: [PATCH] Give the tools an 8MB stack on msvc The wast parser is recursive descent, so nesting depth comes out of the stack, and real modules nest deeply -- a switch lowers to a br_table wrapped in one block per case. esbuild reaches 3457 levels, which msvc's 1MB default cannot parse: wat2wasm faults rather than reporting anything. Ask for the 8MB that Linux and macOS already give us. With that, reading esbuild's own text back works, and a debug build handles 14000 levels. Fixes #2377. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5a14a7ddf..020ad18b75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,6 +506,14 @@ function(wabt_executable) add_dependencies(everything ${EXE_NAME}) target_link_libraries(${EXE_NAME} ${EXE_LIBS}) + if (MSVC) + # The wast parser is recursive descent, so nesting depth costs stack, and + # real modules nest deeply: a switch lowers to a br_table wrapped in one + # block per case. msvc's 1MB default is not enough for that, so ask for + # the 8MB Linux and macOS give us. + target_link_options(${EXE_NAME} PRIVATE "/STACK:8388608") + endif () + if (EMSCRIPTEN) set(EXTRA_LINK_FLAGS "${EXTRA_LINK_FLAGS} -sNODERAWFS -Oz -sALLOW_MEMORY_GROWTH"