summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-31 10:37:30 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2015-08-31 10:37:30 +0000
commit1d9726df12360075758f09a9d62333553fe778f7 (patch)
tree8abc0ef2b196b276af26f60460040f32e81575d8 /libgfortran
parentbfd098e9011473417d2cec61c4b0d1dcd2da77b2 (diff)
downloadgcc-1d9726df12360075758f09a9d62333553fe778f7.tar.gz
PR libfortran/47571
* acinclude.m4 (LIBGFOR_GTHREAD_WEAK): Remove. (LIBGFOR_CHECK_WEAKREF): New test. * configure.ac: Call LIBGFOR_CHECK_WEAKREF instead of LIBGFOR_GTHREAD_WEAK. * config.h.in: Regenerate. * configure: Regenerate. * intrinsics/system_clock.c: Use SUPPORTS_WEAKREF instead of SUPPORTS_WEAK and GTHREAD_USE_WEAK. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227335 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog12
-rw-r--r--libgfortran/acinclude.m436
-rw-r--r--libgfortran/config.h.in7
-rwxr-xr-xlibgfortran/configure47
-rw-r--r--libgfortran/configure.ac4
-rw-r--r--libgfortran/intrinsics/system_clock.c14
6 files changed, 56 insertions, 64 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index d08f050eb31..a6301f1d67d 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,15 @@
+2015-08-31 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR libfortran/47571
+ * acinclude.m4 (LIBGFOR_GTHREAD_WEAK): Remove.
+ (LIBGFOR_CHECK_WEAKREF): New test.
+ * configure.ac: Call LIBGFOR_CHECK_WEAKREF instead of
+ LIBGFOR_GTHREAD_WEAK.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+ * intrinsics/system_clock.c: Use SUPPORTS_WEAKREF instead of
+ SUPPORTS_WEAK and GTHREAD_USE_WEAK.
+
2015-08-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/67367
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index a0975a92a36..fab29e424bf 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -69,27 +69,21 @@ if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);]])],
[Define to 1 if the target supports __sync_fetch_and_add])
fi])
-dnl Check for pragma weak.
-AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
- AC_CACHE_CHECK([whether pragma weak works],
- libgfor_cv_have_pragma_weak, [
- gfor_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wunknown-pragmas"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-void foo (void);
-#pragma weak foo
-]], [[if (foo) foo ();]])],
- libgfor_cv_have_pragma_weak=yes, libgfor_cv_have_pragma_weak=no)])
- if test $libgfor_cv_have_pragma_weak = yes; then
- AC_DEFINE(SUPPORTS_WEAK, 1,
- [Define to 1 if the target supports #pragma weak])
- fi
- case "$host" in
- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
- AC_DEFINE(GTHREAD_USE_WEAK, 0,
- [Define to 0 if the target shouldn't use #pragma weak])
- ;;
- esac])
+dnl Check whether target effectively supports weakref
+AC_DEFUN([LIBGFOR_CHECK_WEAKREF], [
+ AC_CACHE_CHECK([whether the target supports weakref],
+ libgfor_cv_have_weakref, [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wunknown-pragmas -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+static int mytoto (int) __attribute__((__weakref__("toto")));
+]], [[return (mytoto != 0);]])],
+ libgfor_cv_have_weakref=yes, libgfor_cv_have_weakref=no)
+ CFLAGS="$save_CFLAGS"])
+ if test $libgfor_cv_have_weakref = yes; then
+ AC_DEFINE(SUPPORTS_WEAKREF, 1,
+ [Define to 1 if the target supports weakref])
+ fi])
dnl Check whether target can unlink a file still open.
AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index 70a34b113a1..cf8237e0f0c 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -1,8 +1,5 @@
/* config.h.in. Generated from configure.ac by autoheader. */
-/* Define to 0 if the target shouldn't use #pragma weak */
-#undef GTHREAD_USE_WEAK
-
/* Define to 1 if you have the `access' function. */
#undef HAVE_ACCESS
@@ -874,8 +871,8 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define to 1 if the target supports #pragma weak */
-#undef SUPPORTS_WEAK
+/* Define to 1 if the target supports weakref */
+#undef SUPPORTS_WEAKREF
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
diff --git a/libgfortran/configure b/libgfortran/configure
index 546a5a9b55e..12f6f131e61 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -25953,51 +25953,48 @@ $as_echo "#define HAVE_SYNC_FETCH_AND_ADD 1" >>confdefs.h
fi
-# Check out #pragma weak.
+# Check out weakref support.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pragma weak works" >&5
-$as_echo_n "checking whether pragma weak works... " >&6; }
-if test "${libgfor_cv_have_pragma_weak+set}" = set; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports weakref" >&5
+$as_echo_n "checking whether the target supports weakref... " >&6; }
+if test "${libgfor_cv_have_weakref+set}" = set; then :
$as_echo_n "(cached) " >&6
else
- gfor_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wunknown-pragmas"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wunknown-pragmas -Werror"
+ if test x$gcc_no_link = xyes; then
+ as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-void foo (void);
-#pragma weak foo
+static int mytoto (int) __attribute__((__weakref__("toto")));
int
main ()
{
-if (foo) foo ();
+return (mytoto != 0);
;
return 0;
}
_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- libgfor_cv_have_pragma_weak=yes
+if ac_fn_c_try_link "$LINENO"; then :
+ libgfor_cv_have_weakref=yes
else
- libgfor_cv_have_pragma_weak=no
+ libgfor_cv_have_weakref=no
fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_have_pragma_weak" >&5
-$as_echo "$libgfor_cv_have_pragma_weak" >&6; }
- if test $libgfor_cv_have_pragma_weak = yes; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_have_weakref" >&5
+$as_echo "$libgfor_cv_have_weakref" >&6; }
+ if test $libgfor_cv_have_weakref = yes; then
-$as_echo "#define SUPPORTS_WEAK 1" >>confdefs.h
+$as_echo "#define SUPPORTS_WEAKREF 1" >>confdefs.h
fi
- case "$host" in
- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
-
-$as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
-
- ;;
- esac
# Various other checks on target
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 97b91529ebc..fd963ff11b8 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -595,8 +595,8 @@ LIBGFOR_CHECK_ATTRIBUTE_ALIAS
# Check out sync builtins support.
LIBGFOR_CHECK_SYNC_FETCH_AND_ADD
-# Check out #pragma weak.
-LIBGFOR_GTHREAD_WEAK
+# Check out weakref support.
+LIBGFOR_CHECK_WEAKREF
# Various other checks on target
LIBGFOR_CHECK_UNLINK_OPEN_FILE
diff --git a/libgfortran/intrinsics/system_clock.c b/libgfortran/intrinsics/system_clock.c
index ba0bdfe68cb..e36650061ab 100644
--- a/libgfortran/intrinsics/system_clock.c
+++ b/libgfortran/intrinsics/system_clock.c
@@ -45,16 +45,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Weakref trickery for clock_gettime(). On Glibc <= 2.16,
clock_gettime() requires us to link in librt, which also pulls in
libpthread. In order to avoid this by default, only call
- clock_gettime() through a weak reference.
-
- Some targets don't support weak undefined references; on these
- GTHREAD_USE_WEAK is 0. So we need to define it to 1 on other
- targets. */
-#ifndef GTHREAD_USE_WEAK
-#define GTHREAD_USE_WEAK 1
-#endif
-
-#if SUPPORTS_WEAK && GTHREAD_USE_WEAK && defined(HAVE_CLOCK_GETTIME_LIBRT)
+ clock_gettime() through a weak reference. */
+#if SUPPORTS_WEAKREF && defined(HAVE_CLOCK_GETTIME_LIBRT)
static int weak_gettime (clockid_t, struct timespec *)
__attribute__((__weakref__("clock_gettime")));
#endif
@@ -90,7 +82,7 @@ gf_gettime_mono (time_t * secs, long * fracsecs, long * tck)
*fracsecs = ts.tv_nsec;
return err;
#else
-#if defined(HAVE_CLOCK_GETTIME_LIBRT) && SUPPORTS_WEAK && GTHREAD_USE_WEAK
+#if SUPPORTS_WEAKREF && defined(HAVE_CLOCK_GETTIME_LIBRT)
if (weak_gettime)
{
struct timespec ts;