From 7a1e026bb557c07f9b324f5fef64f0a483cbd017 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 9 Dec 2014 18:42:35 +0100 Subject: [PATCH] configure.ac: check for pthread before librt Works around a linker problem with some older glibc versions: if "-lrt" was used, then "-pthread" was implied, but only the symbols used by librt were available. This led to a linker error because pthread_atfork() was not found. So with "-lrt", autoconf decides that no pthread flag is necessary, but in the end fails due to pthread_atfork() missing. By checking for pthread before librt, we avoid this dependency problem. --- configure.ac | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index b58321981..755ff382a 100644 --- a/configure.ac +++ b/configure.ac @@ -193,6 +193,18 @@ dnl --------------------------------------------------------------------------- dnl Header/Library Checks dnl --------------------------------------------------------------------------- +AX_PTHREAD +LIBS="$PTHREAD_LIBS $LIBS" +AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS" +AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS" + +AC_CHECK_LIB([pthread], [pthread_setname_np], + [have_pthread_setname_np=yes], + [have_pthread_setname_np=no]) +if test x$have_pthread_setname_np = xyes; then + AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Is pthread_setname_np() available?]) +fi + AC_SEARCH_LIBS([clock_gettime], [rt]) AC_ARG_ENABLE(syslog, @@ -229,18 +241,6 @@ AC_CHECK_HEADERS(valgrind/memcheck.h) AC_CHECK_HEADERS([sys/prctl.h], AC_CHECK_FUNCS([prctl])) -AX_PTHREAD -LIBS="$PTHREAD_LIBS $LIBS" -AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS" -AM_CXXFLAGS="$AM_CXXFLAGS $PTHREAD_CFLAGS" - -AC_CHECK_LIB([pthread], [pthread_setname_np], - [have_pthread_setname_np=yes], - [have_pthread_setname_np=no]) -if test x$have_pthread_setname_np = xyes; then - AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Is pthread_setname_np() available?]) -fi - dnl --------------------------------------------------------------------------- dnl Event loop selection dnl ---------------------------------------------------------------------------