@@ -2462,6 +2462,54 @@ AS_CASE([$ac_sys_system],
24622462 ]
24632463)
24642464
2465+ dnl On Linux, check the thread stack size. musl (ex: Alpine Linux) uses
2466+ dnl a default thread stack size of 128 kB, whereas the glibc uses 8 MiB.
2467+ dnl Python needs at least 1 MiB.
2468+ if test "$ac_sys_system" = "Linux" -a "$cross_compiling" = no; then
2469+ AC_CACHE_CHECK ( [ for thread stack size] , [ ac_cv_thread_stack_size] , [
2470+ cat > conftest.c <<EOF
2471+ #include <pthread.h>
2472+
2473+ int main()
2474+ {
2475+ pthread_attr_t attrs;
2476+ size_t size;
2477+
2478+ int rc = pthread_attr_init(&attrs);
2479+ if (rc != 0) {
2480+ return 2;
2481+ }
2482+
2483+ rc = pthread_attr_getstacksize(&attrs, &size);
2484+ if (rc != 0) {
2485+ return 2;
2486+ }
2487+
2488+ if (size < 1024 * 1024) {
2489+ return 1;
2490+ }
2491+ return 0;
2492+ }
2493+ EOF
2494+
2495+ ac_cv_thread_stack_size=unknown
2496+ if $CC -pthread $CFLAGS conftest.c -o conftest &>/dev/null; then
2497+ ./conftest &>/dev/null
2498+ exitcode=$?
2499+ if test $exitcode -eq 1; then
2500+ ac_cv_thread_stack_size=1048576
2501+ elif test $exitcode -eq 0; then
2502+ ac_cv_thread_stack_size="default"
2503+ fi
2504+ fi
2505+ rm -f conftest.c conftest
2506+ ] )
2507+
2508+ if test "$ac_cv_thread_stack_size" != "default" -a "$ac_cv_thread_stack_size" != "unknown"; then
2509+ LDFLAGS="$LDFLAGS -Wl,-z,stack-size=$ac_cv_thread_stack_size"
2510+ fi
2511+ fi
2512+
24652513AS_CASE ( [ $enable_wasm_dynamic_linking] ,
24662514 [ yes] , [ ac_cv_func_dlopen=yes] ,
24672515 [ no] , [ ac_cv_func_dlopen=no] ,
0 commit comments