fix: Increase stack size for Windows executables and improve test discovery settings

This commit is contained in:
scawful
2025-10-02 20:58:44 -04:00
parent 0fb8ba4202
commit 56c2132b78

View File

@@ -163,6 +163,17 @@ if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS AND NOT DEFINED ENV{GITHUB_A
ImGui ImGui
) )
# Windows stack size configuration for extract_vanilla_values
if(WIN32)
if(MSVC)
target_link_options(extract_vanilla_values PRIVATE /STACK:16777216)
elseif(MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(extract_vanilla_values PRIVATE -Wl,--stack,16777216)
else()
target_link_options(extract_vanilla_values PRIVATE -Wl,--stack,16777216)
endif()
endif()
# Add rom_patch_utility as a separate executable # Add rom_patch_utility as a separate executable
add_executable( add_executable(
rom_patch_utility rom_patch_utility
@@ -196,6 +207,17 @@ if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS AND NOT DEFINED ENV{GITHUB_A
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
ImGui ImGui
) )
# Windows stack size configuration for rom_patch_utility
if(WIN32)
if(MSVC)
target_link_options(rom_patch_utility PRIVATE /STACK:16777216)
elseif(MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(rom_patch_utility PRIVATE -Wl,--stack,16777216)
else()
target_link_options(rom_patch_utility PRIVATE -Wl,--stack,16777216)
endif()
endif()
endif() endif()
# Configure test executable only when tests are enabled # Configure test executable only when tests are enabled
@@ -256,12 +278,18 @@ endif()
elseif(WIN32) elseif(WIN32)
target_compile_definitions(yaze_test PRIVATE "WINDOWS") target_compile_definitions(yaze_test PRIVATE "WINDOWS")
# Increase stack size on Windows to prevent stack overflow during tests # Increase stack size on Windows to prevent stack overflow during tests
# Use 16MB stack to handle deep call stacks in tests and test discovery
message(STATUS "Configuring Windows stack size for yaze_test to 16MB")
if(MSVC) if(MSVC)
target_link_options(yaze_test PRIVATE /STACK:8388608) # 8MB stack target_link_options(yaze_test PRIVATE /STACK:16777216) # 16MB stack
elseif(MINGW) message(STATUS " Using MSVC linker flag: /STACK:16777216")
target_link_options(yaze_test PRIVATE -Wl,--stack,8388608) elseif(MINGW OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(yaze_test PRIVATE -Wl,--stack,16777216) # 16MB stack
message(STATUS " Using MinGW/GNU linker flag: -Wl,--stack,16777216")
else() else()
target_link_options(yaze_test PRIVATE -Wl,-w) # Fallback for other compilers
target_link_options(yaze_test PRIVATE -Wl,--stack,16777216)
message(STATUS " Using fallback linker flag: -Wl,--stack,16777216")
endif() endif()
endif() endif()
endif() endif()
@@ -272,7 +300,17 @@ if(YAZE_BUILD_TESTS AND NOT YAZE_BUILD_TESTS STREQUAL "OFF")
include(GoogleTest) include(GoogleTest)
# Discover all tests with default properties # Discover all tests with default properties
# On Windows, use NO_PRETTY_TYPES and increased timeout to prevent stack overflow during discovery
if(WIN32)
gtest_discover_tests(yaze_test
DISCOVERY_TIMEOUT 60
NO_PRETTY_TYPES
PROPERTIES
TIMEOUT 300
)
else()
gtest_discover_tests(yaze_test) gtest_discover_tests(yaze_test)
endif()
else() else()
# Tests are disabled - don't build test executable or discover tests # Tests are disabled - don't build test executable or discover tests
message(STATUS "Tests disabled - skipping test executable and discovery") message(STATUS "Tests disabled - skipping test executable and discovery")