+2025-09-20 Bruno Haible <bruno@clisp.org>
+
+ pthread-once: Reduce link dependencies.
+ Linking with -lpthread is not needed on musl libc, macOS, NetBSD,
+ Solaris, Cygwin, Haiku, Android.
+ Reported by Michael Osipov <michael.osipov@innomotics.com> and
+ Tijl Coosemans <tijl@FreeBSD.org> in
+ <https://lists.gnu.org/archive/html/bug-gettext/2025-09/msg00019.html>.
+ * m4/pthread-once.m4 (gl_PTHREAD_ONCE): Require gl_PTHREADLIB. Set
+ PTHREAD_ONCE_LIB.
+ * modules/pthread-once (Link): Link with $(PTHREAD_ONCE_LIB) instead of
+ $(LIBPMULTITHREAD).
+ * modules/pthread-once-tests (Makefile.am): Update accordingly.
+
2025-09-20 Bruno Haible <bruno@clisp.org>
nl_langinfo: Work around nl_langinfo multithread-safety bug on macOS 26.
# pthread-once.m4
-# serial 3
+# serial 4
dnl Copyright (C) 2019-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
AC_REQUIRE([gl_PTHREAD_H])
AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([gl_PTHREADLIB])
if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \
&& test $gl_threads_api = windows; then
dnl Choose function names that don't conflict with the mingw-w64 winpthreads
dnl library.
REPLACE_PTHREAD_ONCE=1
+ PTHREAD_ONCE_LIB=
else
if test $HAVE_PTHREAD_H = 0; then
HAVE_PTHREAD_ONCE=0
+ PTHREAD_ONCE_LIB=
else
dnl Work around Cygwin 3.5.3 bug.
AC_CACHE_CHECK([whether pthread_once works],
*yes) ;;
*) REPLACE_PTHREAD_ONCE=1 ;;
esac
+ dnl Among the platforms where $(LIBPTHREAD) is empty and
+ dnl $(LIBPMULTITHREAD) is non-empty, namely
+ dnl musl libc, macOS, FreeBSD, NetBSD, Solaris, Cygwin, Haiku, Android,
+ dnl $(LIBPMULTITHREAD) is necessary only on FreeBSD.
+ case "$host_os" in
+ freebsd* | dragonfly* | midnightbsd*)
+ PTHREAD_ONCE_LIB="$LIBPMULTITHREAD" ;;
+ *)
+ PTHREAD_ONCE_LIB="$LIBPTHREAD" ;;
+ esac
fi
fi
+ AC_SUBST([PTHREAD_ONCE_LIB])
])
Makefile.am:
TESTS += test-pthread-once1 test-pthread-once2
check_PROGRAMS += test-pthread-once1 test-pthread-once2
-test_pthread_once1_LDADD = $(LDADD) @LIBPMULTITHREAD@
+test_pthread_once1_LDADD = $(LDADD) @PTHREAD_ONCE_LIB@
test_pthread_once2_LDADD = $(LDADD) @LIBPMULTITHREAD@ @SCHED_YIELD_LIB@