coreutils-02-fix-timer-time-m4.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Fix thread detection with uClibc in timer_time.m4
  2. The timer_time.m4 gl_TIMER_TIME function determines which libraries
  3. need to be linked to get access to the timer function, generally -lrt
  4. for Linux systems. On platforms where threads are used, librt
  5. typically uses thread functions from libpthread.
  6. However, the test to determine whether the platform has thread or not
  7. is incorrect: it assumes that if the C library is uClibc, then threads
  8. are not available. This is actually not true: uClibc has configurable
  9. thread support, and when thread support is available, librt calls
  10. libpthread functions.
  11. This is important when static linking is used, because otherwise only
  12. -lrt is used at link time, which fails because librt calls undefined
  13. thread functions. Both -lrt and -lpthread must be passed.
  14. This problem is fixed by making the uClibc thread detection a bit
  15. smarter, thanks to the usage of the __HAS_NO_THREADS__ macro defined
  16. in <bits/uClibc_config.h>, which itself is included by <features.h>.
  17. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  18. Index: b/m4/timer_time.m4
  19. ===================================================================
  20. --- a/m4/timer_time.m4
  21. +++ b/m4/timer_time.m4
  22. @@ -28,7 +28,7 @@
  23. #include <features.h>
  24. #ifdef __GNU_LIBRARY__
  25. #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
  26. - && !defined __UCLIBC__
  27. + && !(__UCLIBC__ && __HAS_NO_THREADS__)
  28. Thread emulation available
  29. #endif
  30. #endif