GNU bug report logs - #10926
Minor problem with static building of coreutils-8.1[345]

Previous Next

Package: coreutils;

Reported by: Heinz-Ado Arnolds <arnolds <at> MPA-Garching.MPG.DE>

Date: Fri, 2 Mar 2012 16:37:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 10926 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: bug-gnulib <bug-gnulib <at> gnu.org>
Cc: 10926 <at> debbugs.gnu.org, Heinz-Ado Arnolds <arnolds <at> MPA-Garching.MPG.DE>
Subject: [PATCH] timer-time: link explicitly with pthreads on glibc
Date: Tue, 06 Mar 2012 16:23:40 +0000
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?= <P <at> draigBrady.com>
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




This bug report was last modified 12 years and 362 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.