bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] timer-time: link explicitly with pthreads on glibc


From: Pádraig Brady
Subject: [PATCH] timer-time: link explicitly with pthreads on glibc
Date: Tue, 06 Mar 2012 16:23:40 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 03/02/2012 09:35 AM, Heinz-Ado Arnolds wrote:
> Hi,
> 
> I have a minor problem with the *static* building of coreutils. Building
> "timeout" requires libpthread in addition to librt.
> 
> A simple patch is enclosed.
> 
> Thanks a lot for your great work and kind regards,
> 

I'm not sure if this is the right approach for the above issue.

cheers,
Pádraig.

>From c18ffcdae1d7ffc012a2cd5dee1e2d0411dcfad8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <address@hidden>
Date: Tue, 6 Mar 2012 15:02:40 +0000
Subject: [PATCH] timer-time: link explicitly with pthreads on glibc

To support static linking we need to explicitly
specify the pthreads library which is referenced
(but not used on modern Linux kernels at least).

* m4/timer_time.m4 (LIB_TIMER_TIME): Add -lpthread
when newer GLIBC is detected as that contains
the pthread emulation.
* modules/timer-time: Depend on threadlib to
pull in the appropriate library to link
---
 m4/timer_time.m4   |   16 ++++++++++++++++
 modules/timer-time |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/m4/timer_time.m4 b/m4/timer_time.m4
index 6276759..d6e0efe 100644
--- a/m4/timer_time.m4
+++ b/m4/timer_time.m4
@@ -11,6 +11,7 @@ AC_DEFUN([gl_TIMER_TIME],
   dnl Based on clock_time.m4. See details there.

   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_REQUIRE([gl_THREADLIB])

   LIB_TIMER_TIME=
   AC_SUBST([LIB_TIMER_TIME])
@@ -18,6 +19,21 @@ AC_DEFUN([gl_TIMER_TIME],
     AC_SEARCH_LIBS([timer_settime], [rt posix4],
                    [test "$ac_cv_search_timer_settime" = "none required" ||
                     LIB_TIMER_TIME=$ac_cv_search_timer_settime])
+    dnl GLIBC uses threads to emulate posix timers when kernel support
+    dnl is not available (like Linux < 2.6 or when used with kFreeBSD)
+    dnl Now the pthread lib is linked automatically in the normal case,
+    dnl but when linking statically, it needs to be explicitly specified.
+    AC_EGREP_CPP([Thread],
+      [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
+     && !defined __UCLIBC__
+  Thread emulation available
+ #endif
+#endif
+      ],
+      [LIB_TIMER_TIME="$LIBMULTITHREAD $LIB_TIMER_TIME"])
     AC_CHECK_FUNCS([timer_settime])
   LIBS=$gl_saved_libs
 ])
diff --git a/modules/timer-time b/modules/timer-time
index 07b439b..7bf8079 100644
--- a/modules/timer-time
+++ b/modules/timer-time
@@ -7,6 +7,7 @@ m4/timer_time.m4

 Depends-on:
 extensions
+threadlib

 configure.ac:
 gl_TIMER_TIME
-- 
1.7.6.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]