tint: Increase Windows debug stack size to 4MB for executables Increase the initial stack size from the 1MB default to 4MB on Windows debug builds for Tint cmd executables in CMake and GN, matching tint_unittests. This prevents stack overflows when validating deeply nested shaders with DXC in CMake MSVC debug builds. Bug: 42250783, 566128737 Change-Id: I7ac2d0dfee155f275d1bd1a18774e61c1ff45095 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/350636 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 64db8bb..ab568d1 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt
@@ -276,17 +276,23 @@ set_target_properties(${TARGET} PROPERTIES FOLDER "Fuzzers") endfunction() +function(tint_cmd_compile_options TARGET) + tint_default_compile_options(${TARGET}) + + if(MSVC AND IS_DEBUG_BUILD) + # TODO(crbug.com/tint/1749): both msvc and clang builds stack overflow on + # debug builds. Increase the initial stack size to 4 MB (default is 1MB). + target_link_options(${TARGET} PRIVATE "/STACK:4194304") + endif() +endfunction() + function(tint_test_cmd_compile_options TARGET) tint_test_compile_options(${TARGET}) - if(MSVC) - # TODO(crbug.com/tint/1749): MSVC debug builds can suffer from stack - # overflows when resolving deeply nested expression chains or statements. - # Production builds neither use MSVC nor debug, so just bump the stack size - # for this build combination. - if(IS_DEBUG_BUILD) - target_link_options(${TARGET} PRIVATE "/STACK:4194304") # 4MB, default is 1MB - endif() + if(MSVC AND IS_DEBUG_BUILD) + # TODO(crbug.com/tint/1749): both msvc and clang builds stack overflow on + # debug builds. Increase the initial stack size to 4 MB (default is 1MB). + target_link_options(${TARGET} PRIVATE "/STACK:4194304") endif() target_link_libraries(${TARGET} PRIVATE gmock) @@ -422,7 +428,7 @@ tint_proto_compile_options(${TARGET}) elseif(${KIND} STREQUAL cmd) add_executable(${TARGET}) - tint_default_compile_options(${TARGET}) + tint_cmd_compile_options(${TARGET}) if (TINT_ENABLE_INSTALL) install(TARGETS "${TARGET}") endif()
diff --git a/src/tint/tint.gni b/src/tint/tint.gni index 3e7cc43..4d59960 100644 --- a/src/tint/tint.gni +++ b/src/tint/tint.gni
@@ -93,6 +93,12 @@ template("tint_executable") { executable(target_name) { forward_variables_from(invoker, "*") + + if (is_win && is_debug) { + # TODO(crbug.com/tint/1749): both msvc and clang builds stack overflow on + # debug builds. Increase the initial stack size to 4 MB (default is 1MB). + ldflags = [ "/STACK:4194304" ] + } } }