On FreeBSD 5.2.1/i386, a testdir shows many link errors for pthread_* functions. Most of these functions exist in libthr.so; there is no libpthread in this version of FreeBSD.
2023-10-15 Bruno Haible <br...@clisp.org> threadlib: Fix link errors on FreeBSD 5.2.1/i386. * m4/threadlib.m4 (gl_PTHREADLIB_BODY): When pthread_kill could not be found in -lpthread, try -lthr. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index 303382881a..855e563d88 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 39 +# threadlib.m4 serial 40 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, @@ -269,6 +269,15 @@ AC_DEFUN([gl_PTHREADLIB_BODY] [Define if the pthread_in_use() detection is hard.]) esac fi + ], + [dnl This is needed on FreeBSD 5.2.1. + AC_CHECK_LIB([thr], [pthread_kill], + [if test $gl_pthread_in_glibc = yes; then + LIBPMULTITHREAD= + else + LIBPMULTITHREAD=-lthr + fi + ]) ]) elif test $gl_pthread_api != yes; then # Some library is needed. Try libpthread and libc_r.