[phobos] clock_gettime changes
Jonathan M Davis
jmdavisProg at gmx.com
Sat Nov 20 19:17:42 PST 2010
On Saturday 20 November 2010 18:33:35 Brad Roberts wrote:
> I removed the -L-lrt from the auto-tester's dmd.conf file and it's still
> failing the phobos tests:
>
> generated/linux/debug/unittest/std/datetime.o: In function
> `_D3std8datetime5Ticks12_staticCtor1OFNeZv':
> /home/braddr/sandbox/d/d-tester/client/3070/phobos-trunk/phobos/std/datetim
> e.d:80: undefined reference to `clock_getres'
> generated/linux/debug/unittest/std/datetime.o: In function
> `_D3std8datetime7systimeFNeZS3std8datetime5Ticks':
> /home/braddr/sandbox/d/d-tester/client/3070/phobos-trunk/phobos/std/datetim
> e.d:666: undefined reference to `clock_gettime'
>
> The druntime tests do pass without linking against librt.
>
> For now, adding librt back again so that the tests pass.
Well, the current version of std.datetime in Phobos checks whether
clock_gettime() is available both for using clock_gettime() and for using
clock_getres(). Both are in librt. Why std.datetime would try to use
clock_getres() when clock_gettime() is unavailable, I don't know.
Really, the ideal situation is that clock_gettime(), clock_gettres(), etc. are
available and used by the time code. That requires linking in librt. Without
that, you cannot have a monotonic clock or a real time clock on Linux. This is
particularly bad for StopWatch and benchmarking code, but it harms the accuracy
of the time code in general. So, I really think that we should have
clock_gettime() and clock_getres() in druntime with -L-lrt in the dmd.conf for
Linux. Unfortunately, they aren't on the Mac, so the time code is going to have
to use whatever the proper function calls are on the Mac, and clock_getttime()
and company will have to be properly versioned so that MacOSX doesn't use them.
But the Linux stuff needs them.
- Jonathan M Davis
More information about the phobos
mailing list