Skip to content

Commit 78d1e9b

Browse files
authored
Specify default thread stack size for musl (#343)
The musl libc by default sets up threads to have [128kB of stack](https://wiki.musl-libc.org/functional-differences-from-glibc.html). We explicitly set our desired default stack size in the PT_GNU_STACK header with this linker command. musl reads this header to determine the default thread stack size. 2MB is approximately the glibc default. Bench: 13566775
1 parent d2c5f62 commit 78d1e9b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ function(target_add_flags target)
6666
-fsanitize=address,undefined
6767
>)
6868

69+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
70+
target_link_options(${target} PUBLIC
71+
-Wl,-z,stack-size=2097152)
72+
endif()
73+
6974
# Include directories
7075
target_include_directories(${target} PUBLIC src)
7176

0 commit comments

Comments
 (0)