Skip to content

Commit 857c42b

Browse files
committed
Set default stack size on Windows
When compiling with MSVC (that includes ClangCL) it defaults to 1MB, which means our default of 1MB in the interpreter is too large to detect actual overflow. When compiling with MinGW GCC/Clang it defaults to 2MB. Set it to 8MB like Linux for some consistency.
1 parent 55c06f1 commit 857c42b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ if(MSVC)
7070
xcheck_add_c_compiler_flag(/wd5045) # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
7171
endif()
7272

73+
# Set a 8MB default stack size on Windows.
74+
# It defaults to 1MB on MSVC, which is the same as our current JS stack size,
75+
# so it will overflow and crash otherwise.
76+
# On MinGW it defaults to 2MB.
77+
if(WIN32)
78+
if(MSVC)
79+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608")
80+
else()
81+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,8388608")
82+
endif()
83+
endif()
84+
7385
# MacOS and GCC 11 or later need -Wno-maybe-uninitialized
7486
# https://github.com/quickjs-ng/quickjs/issues/453
7587
if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11)

0 commit comments

Comments
 (0)