[Patch, libfortran] PR 47571 Fix static linking regression
Janne Blomqvist
blomqvist.janne@gmail.com
Tue Feb 1 21:12:00 GMT 2011
Hi,
my recent patch to use clock_gettime() made static linking break on
Linux, since the driver didn't link in librt. It was also pointed out
that always requiring librt in libgfortran might in principle reduce
performance for non-threaded programs as librt pulls in libpthread and
thus the weakrefed IO locking stuff becomes real locks.
The attached patch fixes this by not linking in librt (and this
libpthread) in libgfortran.so, and instead calls clock_gettime()
through a weak reference, falling back to gettimeofday()/other
fallbacks in case librt is not explicitly linked in (or implicitly
e.g. via -fopenmp). For platforms that provide clock_gettime() in
libc, clock_gettime() ought to always be used, although I'm not able
to test this.
Regtested on x86_64-unknown-linux-gnu, tested a simple program to
ensure usage of clock_gettime() or gettimeofday() depending on whether
librt is linked. Ok for trunk?
2011-02-01 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47571
* configure: Regenerated.
* configure.ac: Don't add librt to LIBS.
* intrinsics/time_1.h (weak_gettime): Weakref trickery for
clock_gettime().
(gf_gettime): Use weak_gettime() instead of clock_gettime().
--
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: weak_gettime.diff
Type: text/x-patch
Size: 2468 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20110201/79d04b11/attachment.bin>
More information about the Fortran
mailing list