From patchwork Mon Apr 11 20:18:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Blomqvist X-Patchwork-Id: 90647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 98D8BB6F14 for ; Tue, 12 Apr 2011 06:19:09 +1000 (EST) Received: (qmail 16336 invoked by alias); 11 Apr 2011 20:19:07 -0000 Received: (qmail 16308 invoked by uid 22791); 11 Apr 2011 20:18:59 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_BG, TW_LR X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Apr 2011 20:18:54 +0000 Received: by pzk35 with SMTP id 35so3353754pzk.20 for ; Mon, 11 Apr 2011 13:18:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.26.12 with SMTP id d12mr5737800wfj.333.1302553134051; Mon, 11 Apr 2011 13:18:54 -0700 (PDT) Received: by 10.68.48.201 with HTTP; Mon, 11 Apr 2011 13:18:53 -0700 (PDT) Date: Mon, 11 Apr 2011 23:18:53 +0300 Message-ID: Subject: [Patch, libfortran] PR 47571 Fix bootstrap failure on alpha*-dec-osf* From: Janne Blomqvist To: Fortran List , GCC Patches Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, the attached patch hopefully fixes the bootstrap failure on alpha*-dec-osf* due to said platform having clock_gettime() in librt, supporting weak symbols but not weak undefined symbols. The patch is the same as #38 in the PR discussion + adding alpha*-dec-osf* to the acinclude.m4 blacklist. Regtested on x86_64-unknown-linux-gnu, Ok for trunk? Once in trunk for a short while, Ok to backport to the 4.6 branch and replace the quick-and-dirty hack that was introduced to fix this shortly before 4.6 release? Many thanks to Rainer Orth for testing. 2011-04-11 Janne Blomqvist PR libfortran/47571 * configure: Regenerated. * config.h.in: Regenerated. * acinclude.m4: Add alpha*-dec-osf* to gthread blacklist. * configure.ac: Use separate symbol for clock_gettime in librt. * intrinsics/system_clock.c: Use weakrefs only when needed and supported. diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index acd1d4d..92e0271 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -110,7 +110,7 @@ void foo (void); [Define to 1 if the target supports #pragma weak]) fi case "$host" in - *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* ) + *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | alpha*-dec-osf* ) AC_DEFINE(GTHREAD_USE_WEAK, 0, [Define to 0 if the target shouldn't use #pragma weak]) ;; diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 588f999..9b36103 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -491,14 +491,15 @@ LIBGFOR_CHECK_FLOAT128 # Check for GNU libc feenableexcept AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])]) -# At least for glibc, clock_gettime is in librt. But don't pull that -# in if it still doesn't give us the function we want. -# This test is copied from libgomp, and modified to not link in -lrt -# as libgfortran calls clock_gettime via a weak reference. +# At least for glibc and Tru64, clock_gettime is in librt. But don't +# pull that in if it still doesn't give us the function we want. This +# test is copied from libgomp, and modified to not link in -lrt as +# libgfortran calls clock_gettime via a weak reference if it's found +# in librt. if test $ac_cv_func_clock_gettime = no; then AC_CHECK_LIB(rt, clock_gettime, - [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, - [Define to 1 if you have the `clock_gettime' function.])]) + [AC_DEFINE(HAVE_CLOCK_GETTIME_LIBRT, 1, + [Define to 1 if you have the `clock_gettime' function in librt.])]) fi # Check for SysV fpsetmask diff --git a/libgfortran/intrinsics/system_clock.c b/libgfortran/intrinsics/system_clock.c index 3a44dd9..f4bac07 100644 --- a/libgfortran/intrinsics/system_clock.c +++ b/libgfortran/intrinsics/system_clock.c @@ -29,14 +29,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "time_1.h" -#ifdef HAVE_CLOCK_GETTIME + /* POSIX states that CLOCK_REALTIME must be present if clock_gettime is available, others are optional. */ +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_GETTIME_LIBRT) #ifdef CLOCK_MONOTONIC #define GF_CLOCK_MONOTONIC CLOCK_MONOTONIC #else #define GF_CLOCK_MONOTONIC CLOCK_REALTIME #endif +#endif /* Weakref trickery for clock_gettime(). On Glibc, clock_gettime() requires us to link in librt, which also pulls in libpthread. In @@ -50,15 +52,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define GTHREAD_USE_WEAK 1 #endif -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK && defined(HAVE_CLOCK_GETTIME_LIBRT) static int weak_gettime (clockid_t, struct timespec *) __attribute__((__weakref__("clock_gettime"))); -#else -static inline int weak_gettime (clockid_t clk_id, struct timespec *res) -{ - return clock_gettime (clk_id, res); -} -#endif #endif @@ -84,6 +80,13 @@ gf_gettime_mono (time_t * secs, long * nanosecs) { int err; #ifdef HAVE_CLOCK_GETTIME + struct timespec ts; + err = clock_gettime (GF_CLOCK_MONOTONIC, &ts); + *secs = ts.tv_sec; + *nanosecs = ts.tv_nsec; + return err; +#else +#if defined(HAVE_CLOCK_GETTIME_LIBRT) && SUPPORTS_WEAK && GTHREAD_USE_WEAK if (weak_gettime) { struct timespec ts; @@ -96,6 +99,7 @@ gf_gettime_mono (time_t * secs, long * nanosecs) err = gf_gettime (secs, nanosecs); *nanosecs *= 1000; return err; +#endif } extern void system_clock_4 (GFC_INTEGER_4 *, GFC_INTEGER_4 *, GFC_INTEGER_4 *);