Details
-
Suggestion
-
Resolution: Done
-
P4: Low
-
5.3.1
-
None
-
9d90bbd7b14db17a64e6a664e6f98b58efa97747
Description
Qt's configure script unconditionally looks in -lrt for clock_gettime on Linux: qtbase/config.tests/unix/clock-gettime/clock-gettime.pri reads
# clock_gettime() is implemented in librt on these systems linux-*|hpux-*|solaris-*:LIBS_PRIVATE *= -lrt
However, clock_gettime (and all the other clock_* functions) were moved to the base libc in GNU libc 2.17. Here's the relevant entry from the release notes:
* The `clock_*' suite of functions (declared in <time.h>) is now available directly in the main C library. Previously it was necessary to link with -lrt to use these functions. This change has the effect that a single-threaded program that uses a function such as `clock_gettime' (and is not linked with -lrt) will no longer implicitly load the pthreads library at runtime and so will not suffer the overheads associated with multi-thread support in other code such as the C++ runtime library.
QtBase needs to load the pthreads library anyway, so this isn't much of a big deal, but it would still be nice if the configure test were modified so that when built against glibc >=2.17, the library did not pull in librt. If I understand correctly, alternative C libraries for Linux, e.g. uclibc and musl, have also made this change, so if at all possible the test should not rely on specific version numbers, but rather try to link clock-gettime.cpp with no additional libraries, and only if that fails try -lrt.
Attachments
For Gerrit Dashboard: QTBUG-41009 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
196966,2 | rework detection and use of clock_gettime()/librt | 5.9 | qt/qtbase | Status: MERGED | +2 | 0 |