This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: libstdc++ wants clock_gettime without libpthread
On Thu, Oct 18, 2012 at 05:22:46PM -0700, Roland McGrath wrote:
> That is a worthy goal and unfortunately it does not have a very simple
> solution.
>
> librt unavoidably uses pthread calls because the aio, mq, and timer
> interfaces include the (dynamic) possibility of SIGEV_THREAD, which
> obviously has to use pthread_create (and could legitimately be used in a
> program that didn't make any direct pthread calls itself).
>
> There are several things we could potentially do, but none is without some
> kind of complication.
>
> 1. Just move clock_* calls into libc.
This is what should be done, and what should have been done years
ago...
> Pro: That solves the problem for libstdc++ with almost no special effort
> at all on the libstdc++ side. If building libstdc++ just uses -lc
> -Wl,--as-needed -lrt then it will be compatible with old
> installations where you need to get it from librt, and with new
> ones where you can get it from libc and won't generate a DT_NEEDED
> on librt.so.N (without requiring configure-time checks to influence
> the linking details).
>
> Con:
> a. It bloats libc.so.N with code, and its permanent ABI with symbols,
> that most applications do not need.
I don't see this as a con. clock_* is the modern clock API that all
applications should be using. The only reason applications are still
using the gettimeofday function instead is to avoid -lrt.
Rich