[
Date Prev][Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [mosquitto-dev] why is librt needed?
|
Apologies for the delay on the follow-up. Ran out of town for a few
days...
> Thanks. So you are saying that the only thing mosquitto needs that
> might be related to "POSIX realtime" is clock_gettime and friends.
I didn't do an extensive search, but did a quick grep of the
mosquitto sources for some arcane stuff, like POSIX message queues
(mq_*) and semaphores, came up empty. But clock_gettime() was in
there.
On my Linux distro (Mint 22) the
librt.a archive is just an
empty stub of a library. There's nothing in it. I assume they left
it in there to appease all the build systems that still include it.
Frank
On 7/12/25 09:27, Greg Troxel wrote:
Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx> writes:
Originally, librt contained (among other things) the "advanced" POSIX
clock and timer functions, like clock_gettime(). So, if you wanted
access to the monotonic clock, you needed librt. But these functions
became fairly mainstream and most system libraries started absorbing
them. According to the Linux man page, glibc implemented
clock_gettime() and related functions in v2.17 (released in 2012).
So I'm guessing it is pretty system dependent on where it's still needed.
Thanks. So you are saying that the only thing mosquitto needs that
might be related to "POSIX realtime" is clock_gettime and friends.
Looking at POSIX
https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_getres.html
It says
Issue 7
Functionality relating to the Clock Selection option is moved to the
Base.
The clock_getres(), clock_gettime(), and clock_settime() functions
are moved from the Timers option to the Base.
POSIX.1-2008, Technical Corrigendum 1, XSH/TC1-2008/0058 [106] is
applied.
so for any system that complies with POSIX 2008, then the functions have
to be available from time.h and there's no need to include a library.
I suggest therefore, that the code to include -lrt be dropped, and then
if there is a system that needs it, there be a
if system is special_system_that_needs_librt
add rt
endif
rather than "add it except on this list of systems", which
- invites patching to add every system that doesn't need it
- undesirable behavior on systems not patched for, which is contrary
to autoconf norms.
Are we aware of systems that do need -lrt to make clock_gettime work?
It seems that the upcoming 2.1 is a good time to excise this and see if
it's actually needed.
Also, there's special APPLE stuff surrounding clock_gettime and using
something else, but macOS has clock_gettime, as far back as 10.13. I
personally don't think 10.13 is relevant any more, and versions below
10.13 are even less likely.