This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, v3] Potential solution to librt issue.


Hi Paolo,

and, first thanks for your help.

> I'm not saying it is a "no-no" to use clock_gettime -- but I
> guess  you'll agree it is a "no-no" to break performance of single-threaded
> programs because of it, and it is lucky that Dan brought up the point so 
> soon.

Agreed.

> 
> Possibilities include:
> 
> 1) implementing clock_gettime on Linux using the system call
> interface. 
>   I guess that the clock_gettime syscall itself does not need
> pthreads.
> 
> 2) do some trick with specs.  For example, -Wl,--as-needed
> -lrt does not bring in pthreads unless necessary:
> 
> $ gcc f.c -Wl,--as-needed -lrt
> $ ldd a.out
>          linux-gate.so.1 =>  (0xffffe000)
>          libc.so.6 => /lib/libc.so.6 (0xb7da9000)
>          /lib/ld-linux.so.2 (0xb7ef8000)
> 
> Is <chrono> a template?  If yes, i.e. if there is no code in
> libstdc++.so that needs clock_gettime, you could add the 
> "-Wl,--as-needed -lrt -Wl,--no-as-needed" flags to the specs
> for C++ on Linux.

Interesting. Let's clarify a bit then: <chrono> includes templates, but clock_gettime is used only by a normal class, system_clock, only by its member function now, exported by the .so. This is the situation.

What does this imply for your idea? I understand, correct me if I'm wrong, that not-exporting the symbol, arranging for the call to be inside an header, would make the issue easier to solve. But then, what would happen if the user code actually uses now? Would have to be linked on a case-by-case basic to libpthread? This, as I said already, I don't like at all, long term cannot be ok, the user, basing on the C++0x specifications, cannot be assumed to know that a clock requires such library.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]