Gnulib's multithreading implementation can, on mingw, be based on mingw's libwinpthread or on native Windows primitives.
But it makes a difference on the 'test-pthread-tss' test: With mingw 5.0.3 libwinpthread it fails like this: Starting test_tss ... OK Starting test_tss_dtorcheck1 ... OK Starting test_tss_dtorcheck2 ... OK Starting test_tss_racecheck ...FAIL test-pthread-tss.exe (exit status: 127) With mingw 10.0.0 libwinpthread, more than 5 years later [2], it fails like this: Starting test_tss ... OK Starting test_tss_dtorcheck1 ... OK Starting test_tss_dtorcheck2 ... OK Starting test_tss_racecheck ...../../gltests/test-pthread-tss.c:469: assertion 'pthread_setspecific (keys[i], (void *) (uintptr_t) (10 * id + i + 1)) == 0' failed FAIL test-pthread-tss.exe (exit status: 3) Whereas without libwinpthread, this test succeeds. I had hoped that they would fix this TSS/TLS implementation over the years. But this does not happen, apparently. So it's time for Gnulib to no longer use libwinpthread by default. So that programs no longer have to invoke gl_AVOID_WINPTHREAD in order to get something that works reliably. [1] https://www.gnu.org/software/gnulib/manual/html_node/Gnulib-multithreading.html [2] https://www.mingw-w64.org/changelog/ 2023-04-22 Bruno Haible <br...@clisp.org> threadlib, pthread-h, threads-h: Avoid mingw's libwinpthread by default. * m4/threadlib.m4 (gl_THREADLIB_EARLY_BODY): Set gl_use_winpthreads_default to 'no' by default. (gl_AVOID_WINPTHREAD): Update comments. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index c19d047221..4348dc3291 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 36 +# threadlib.m4 serial 37 dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -439,7 +439,9 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY] m4_ifdef([gl_THREADLIB_DEFAULT_NO], [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) - m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=]) + dnl gl_use_winpthreads_default defaults to 'no', because in mingw 10, like + dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash. + m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no]) AC_ARG_ENABLE([threads], AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ AS_HELP_STRING([--disable-threads], [build without multithread safety])]), @@ -605,7 +607,8 @@ AC_DEFUN([gl_DISABLE_THREADS] dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. dnl The user can still override it at installation time, by using the -dnl configure option '--enable-threads'. +dnl configure option '--enable-threads=posix'. +dnl As of 2023, this is now the default. AC_DEFUN([gl_AVOID_WINPTHREAD], [ m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])