build: use -lrt for clock_gettime on glibc < 2.17
Subsystems (2)
PATCH 1/1 build: use -lrt for clock_gettime on glibc < 2.17
From: "Dirk-Jan C. Binnema" <[email protected]>
glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime. AC_SEARCH_LIBS adds it to LIBS in that case
--- configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac +1 -0
@@ -40,6 +40,7 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], AC_CHECK_FUNC(signalfd, dummy=yes, AC_MSG_ERROR(signalfd support is required)) +AC_SEARCH_LIBS(clock_gettime,rt) AC_CHECK_FUNC(clock_gettime, dummy=yes, AC_MSG_ERROR(realtime clock support is required))
Signature · 1 line
1.8.3.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Marcel,
Quoted 16 lines · [email protected] writes:
Hi Dirk-Jan,,
Quoted 14 lines
glibc before 2.17 (e.g., fedora 18) requires -lrt for
clock_gettime.AC_SEARCH_LIBSadds it to LIBS in that case
---
configure.ac | 1 +1 file changed, 1 insertion(+)configure.ac +0
-0@@ -40,6 +40,7 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], AC_CHECK_FUNC(signalfd, dummy=yes, AC_MSG_ERROR(signalfd support is required))
Quoted 3 lines
configure.ac AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], · line 43
Quoted 1 line
configure.ac +1
-0+AC_SEARCH_LIBS(clock_gettime,rt)I do like this since this now it links everything with -lrt even if it is not needed.
Hmm, I suppose there's a missing 'not'...
Note, AC_SEARCH_LIBS tries without rt first, and only adds -lrt if clock_gettime is not defined without it.
Or did you mean building parts of bluez without -lrt in the glibc < 2.17 case? If so, please see my next patch, which only uses -lrt (if needed) for bluetoothd.
Cheers,
Dirk.
Signature · 3 lines
Dirk-Jan C. Binnema Helsinki, Finland e:[email protected] w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
PATCH 1/1 build: use -lrt for clock_gettime on glibc < 2.17
In reply to a message not in the archiveFrom: "Dirk-Jan C. Binnema" <[email protected]>
glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime; add -lrt where needed in that case.
--- Makefile.am | 2 +- configure.ac | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
Makefile.am +1 -1
@@ -152,7 +152,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \ src/shared/util.h src/shared/util.c \ src/shared/mgmt.h src/shared/mgmt.c src_bluetoothd_LDADD = lib/libbluetooth-internal.la gdbus/libgdbus-internal.la \ - @GLIB_LIBS@ @DBUS_LIBS@ -ldl -lrt + @GLIB_LIBS@ @DBUS_LIBS@ @RT_LIBS@ -ldl src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \ -Wl,--version-script=$(srcdir)/src/bluetooth.ver
configure.ac +4 -2
@@ -40,8 +40,10 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads], AC_CHECK_FUNC(signalfd, dummy=yes, AC_MSG_ERROR(signalfd support is required)) -AC_CHECK_FUNC(clock_gettime, dummy=yes, - AC_MSG_ERROR(realtime clock support is required)) +AC_CHECK_FUNC(clock_gettime, [], [ + AC_CHECK_LIB(rt, clock_gettime, RT_LIBS="-lrt", + AC_MSG_ERROR(realtime clock support is required))]) +AC_SUBST(RT_LIBS) AC_CHECK_LIB(pthread, pthread_create, dummy=yes, AC_MSG_ERROR(posix thread support is required))
Signature · 1 line
1.8.3.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · [email protected] writes:
Hi Dirk-Jan,
<snip>
Quoted 4 lines
so I fixed this upstream a lot simpler by always checking for
clock_gettimein -lrt. Can you check if that works for you. On an older Debian test box it just works fine for me.
Sure, that works; but that's equivalent to the first patch I made... I only made the more complicated one after your comment:
,----
| > +AC_SEARCH_LIBS(clock_gettime,rt) | | I do [not] like this since this now it links everything with -lrt even if it | is not needed.
`----
AC_SEARCH_LIBS doesn't add -lrt if it's not needed, so I interpreted your comment as you not wanting -lrt in parts of the code that don't need it.
Anyway, good it works now...
Thanks,
Dirk.
Signature · 3 lines
Dirk-Jan C. Binnema Helsinki, Finland e:[email protected] w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
Hi Dirk-Jan,
Quoted 8 lines · Dirk-Jan C. Binnema
From: "Dirk-Jan C. Binnema" <[email protected]>
glibc before 2.17 (e.g., fedora 18) requires -lrt for
clock_gettime; add -lrt where needed in that case.--- Makefile.am | 2 +- configure.ac | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
It seems Marcel went ahead and applied his own patch for this (I think he didn't realize there was a pending one here). Could you check if latest git now works for you?
Johan