summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/ChangeLog4
-rw-r--r--config/weakref.m448
-rw-r--r--libitm/ChangeLog16
-rw-r--r--libitm/Makefile.in10
-rw-r--r--libitm/aclocal.m41
-rw-r--r--libitm/alloc_cpp.cc4
-rw-r--r--libitm/config.h.in3
-rw-r--r--libitm/configure51
-rw-r--r--libitm/configure.ac2
-rw-r--r--libitm/eh_cpp.cc4
-rw-r--r--libitm/testsuite/Makefile.in10
11 files changed, 139 insertions, 14 deletions
diff --git a/config/ChangeLog b/config/ChangeLog
index 4f202ffbc9af..4ebecc32f703 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,7 @@
+2011-11-22 Iain Sandoe <iains@gcc.gnu.org>
+
+ * weakref.m4: New file.
+
2011-11-09 Richard Henderson <rth@redhat.com>
* asmcfi.m4: New file.
diff --git a/config/weakref.m4 b/config/weakref.m4
new file mode 100644
index 000000000000..39b63d39b8ab
--- /dev/null
+++ b/config/weakref.m4
@@ -0,0 +1,48 @@
+
+dnl Check if the target supports weak.
+AC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [
+ AC_CACHE_CHECK([whether the target supports weak],
+ ac_cv_have_attribute_weak, [
+ weakref_m4_saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror"
+ AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }],
+ [], ac_cv_have_attribute_weak=yes,
+ ac_cv_have_attribute_weak=no)
+ CFLAGS="$weakref_m4_saved_CFLAGS"])
+ if test x"$ac_cv_have_attribute_weak" = xyes; then
+ AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1,
+ [Define to 1 if the target supports __attribute__((weak)).])
+ fi])
+
+dnl Check whether weak refs work like the ELF ones.
+dnl This means that the weak reference works without having to satify
+dnl linkage for the item.
+dnl There are targets (at least Darwin) where we have fully functional
+dnl weakrefs at runtime, but must supply the referenced item at link time.
+AC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [
+ AC_CACHE_CHECK([whether weak refs work like ELF],
+ ac_cv_have_elf_style_weakref, [
+ weakref_m4_saved_CFLAGS="$CFLAGS"
+ case "${host}" in
+ *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
+ *) ;;
+ esac
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+extern void fNotToBeFound(void) __attribute__((weak));
+int main ()
+{
+ if (fNotToBeFound)
+ return 1;
+ else
+ return 0;
+}
+]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [
+case "${host}" in
+ alpha*-dec-osf*) ac_cv_have_elf_style_weakref=no ;;
+ *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;;
+ *) ac_cv_have_elf_style_weakref=yes;;
+esac])CFLAGS="$weakref_m4_saved_CFLAGS"])
+if test x"$ac_cv_have_elf_style_weakref" = xyes; then
+ AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref that works like the ELF one.])
+fi])
+
diff --git a/libitm/ChangeLog b/libitm/ChangeLog
index ae091d871810..ab21cc5b99d2 100644
--- a/libitm/ChangeLog
+++ b/libitm/ChangeLog
@@ -1,11 +1,23 @@
2011-11-22 Iain Sandoe <iains@gcc.gnu.org>
+ * configure.ac: Use GCC_CHECK_ELF_STYLE_WEAKREF.
+ * alloc_cpp.cc: Generate dummy functions if we don't
+ HAVE_ELF_STYLE_WEAKREF.
+ * eh_cpp.cc: Likewise.
+ * configure: Regenerate.
+ * aclocal.m4: Likewise.
+ * config.h.in: Likewise.
+ * Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+
+2011-11-22 Iain Sandoe <iains@gcc.gnu.org>
+
* config/x86/sjlj.S (CONCAT1, CONCAT2, SYM): Respond to
__USER_LABEL_PREFIX__ for targets that use it.
- TYPE, SIZE, HIDDEN): New macros to assist on non-elf targets.
+ (TYPE, SIZE, HIDDEN): New macros to assist on non-elf targets.
(_ITM_beginTransaction): Use SYM, TYPE, SIZE macros to assist
in portability to non-elf targets.
- (GTM_longjmp): LIkewise.
+ (GTM_longjmp): Likewise.
* libitm_i.h (begin_transaction): Apply __USER_LABEL_PREFIX__
where required.
diff --git a/libitm/Makefile.in b/libitm/Makefile.in
index d3872c9d36e7..a1bc47645e09 100644
--- a/libitm/Makefile.in
+++ b/libitm/Makefile.in
@@ -57,10 +57,12 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../config/multi.m4 \
$(top_srcdir)/../config/override.m4 \
$(top_srcdir)/../config/stdint.m4 \
- $(top_srcdir)/../config/tls.m4 $(top_srcdir)/../ltoptions.m4 \
- $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
- $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/../config/tls.m4 \
+ $(top_srcdir)/../config/weakref.m4 \
+ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
diff --git a/libitm/aclocal.m4 b/libitm/aclocal.m4
index 96617e6e4db9..625404e06f67 100644
--- a/libitm/aclocal.m4
+++ b/libitm/aclocal.m4
@@ -1001,6 +1001,7 @@ m4_include([../config/multi.m4])
m4_include([../config/override.m4])
m4_include([../config/stdint.m4])
m4_include([../config/tls.m4])
+m4_include([../config/weakref.m4])
m4_include([../ltoptions.m4])
m4_include([../ltsugar.m4])
m4_include([../ltversion.m4])
diff --git a/libitm/alloc_cpp.cc b/libitm/alloc_cpp.cc
index d298bd49e820..0789b2e53429 100644
--- a/libitm/alloc_cpp.cc
+++ b/libitm/alloc_cpp.cc
@@ -60,7 +60,7 @@ extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
-#ifdef __osf__ /* Really: !HAVE_WEAKDEF */
+#if !defined (HAVE_ELF_STYLE_WEAKREF)
void *_ZnwX (size_t) { return NULL; }
void _ZdlPv (void *) { return; }
void *_ZnaX (size_t) { return NULL; }
@@ -70,7 +70,7 @@ void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) { return NULL; }
void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) { return NULL; }
void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
-#endif /* __osf__ */
+#endif /* HAVE_ELF_STYLE_WEAKREF */
/* Wrap the delete nothrow symbols for usage with a single argument.
Perhaps should have a configure type check for this, because the
diff --git a/libitm/config.h.in b/libitm/config.h.in
index 52db1a6fdc1c..1c3469cd5f95 100644
--- a/libitm/config.h.in
+++ b/libitm/config.h.in
@@ -30,6 +30,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
+/* Define to 1 if target has a weakref that works like the ELF one. */
+#undef HAVE_ELF_STYLE_WEAKREF
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
diff --git a/libitm/configure b/libitm/configure
index 024f39688bf3..9b0635941119 100644
--- a/libitm/configure
+++ b/libitm/configure
@@ -17213,6 +17213,57 @@ $as_echo "#define HAVE_AS_AVX 1" >>confdefs.h
;;
esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether weak refs work like ELF" >&5
+$as_echo_n "checking whether weak refs work like ELF... " >&6; }
+if test "${ac_cv_have_elf_style_weakref+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ weakref_m4_saved_CFLAGS="$CFLAGS"
+ case "${host}" in
+ *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
+ *) ;;
+ esac
+ if test "$cross_compiling" = yes; then :
+
+case "${host}" in
+ alpha*-dec-osf*) ac_cv_have_elf_style_weakref=no ;;
+ *-apple-darwin[89]*) ac_cv_have_elf_style_weakref=no ;;
+ *) ac_cv_have_elf_style_weakref=yes;;
+esac
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+extern void fNotToBeFound(void) __attribute__((weak));
+int main ()
+{
+ if (fNotToBeFound)
+ return 1;
+ else
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_have_elf_style_weakref=yes
+else
+ ac_cv_have_elf_style_weakref=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+CFLAGS="$weakref_m4_saved_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_elf_style_weakref" >&5
+$as_echo "$ac_cv_have_elf_style_weakref" >&6; }
+if test x"$ac_cv_have_elf_style_weakref" = xyes; then
+
+$as_echo "#define HAVE_ELF_STYLE_WEAKREF 1" >>confdefs.h
+
+fi
+
# Cleanup and exit.
CFLAGS="$save_CFLAGS"
cat >confcache <<\_ACEOF
diff --git a/libitm/configure.ac b/libitm/configure.ac
index 672b71279e38..45ee8701e385 100644
--- a/libitm/configure.ac
+++ b/libitm/configure.ac
@@ -239,6 +239,8 @@ LIBITM_CHECK_SYNC_BUILTINS
LIBITM_CHECK_64BIT_SYNC_BUILTINS
LIBITM_CHECK_AS_AVX
+GCC_CHECK_ELF_STYLE_WEAKREF
+
# Cleanup and exit.
CFLAGS="$save_CFLAGS"
AC_CACHE_SAVE
diff --git a/libitm/eh_cpp.cc b/libitm/eh_cpp.cc
index 7a378622772e..6f302cdc4aee 100644
--- a/libitm/eh_cpp.cc
+++ b/libitm/eh_cpp.cc
@@ -39,13 +39,13 @@ extern void *__cxa_begin_catch (void *) WEAK;
extern void *__cxa_end_catch (void) WEAK;
extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
-#ifdef __osf__ /* Really: !HAVE_WEAKDEF */
+#if !defined (HAVE_ELF_STYLE_WEAKREF)
void *__cxa_allocate_exception (size_t) { return NULL; }
void __cxa_throw (void *, void *, void *) { return; }
void *__cxa_begin_catch (void *) { return NULL; }
void *__cxa_end_catch (void) { return NULL; }
void __cxa_tm_cleanup (void *, void *, unsigned int) { return; }
-#endif
+#endif /* HAVE_ELF_STYLE_WEAKREF */
}
diff --git a/libitm/testsuite/Makefile.in b/libitm/testsuite/Makefile.in
index 6990cfeb6812..8066a2a03886 100644
--- a/libitm/testsuite/Makefile.in
+++ b/libitm/testsuite/Makefile.in
@@ -47,10 +47,12 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../config/multi.m4 \
$(top_srcdir)/../config/override.m4 \
$(top_srcdir)/../config/stdint.m4 \
- $(top_srcdir)/../config/tls.m4 $(top_srcdir)/../ltoptions.m4 \
- $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
- $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/../config/tls.m4 \
+ $(top_srcdir)/../config/weakref.m4 \
+ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs