Patchwork libgo patch committed: Check for setjmp/longjmp exceptions

login
register
mail settings
Submitter Ian Taylor
Date Feb. 3, 2011, 1:53 a.m.
Message ID <mcrpqr9c28t.fsf@google.com>
Download mbox | patch
Permalink /patch/81608/
State New
Headers show

Comments

Ian Taylor - Feb. 3, 2011, 1:53 a.m.
This patch to libgo checks whether we are using setjmp/longjmp
exceptions, which changes one of the functions called when unwinding the
stack.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 51961799b012 libgo/configure.ac
--- a/libgo/configure.ac	Wed Feb 02 10:40:30 2011 -0800
+++ b/libgo/configure.ac	Wed Feb 02 17:48:18 2011 -0800
@@ -328,6 +328,56 @@ 
 
 GCC_CHECK_UNWIND_GETIPINFO
 
+AC_ARG_ENABLE(sjlj-exceptions,
+  AC_HELP_STRING([--enable-sjlj-exceptions],
+		 [force use of builtin_setjmp for exceptions]),
+  [case "$enableval" in
+   yes|no|auto) ;;
+   *) AC_MSG_ERROR([unknown argument to --enable-sjlj-exceptions]) ;;
+   esac],
+  [enable_sjlj_exceptions=auto])
+
+AC_CACHE_CHECK([whether to use setjmp/longjmp exceptions],
+[libgo_cv_lib_sjlj_exceptions],
+[AC_LANG_CONFTEST(
+  [AC_LANG_SOURCE([
+void bar ();
+void clean (int *);
+void foo ()
+{
+  int i __attribute__ ((cleanup (clean)));
+  bar();
+}
+])])
+CFLAGS_hold=$CFLAGS
+CFLAGS="--save-temps -fexceptions"
+libgo_cv_lib_sjlj_exceptions=unknown
+AS_IF([ac_fn_c_try_compile],
+  [if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1; then
+    libgo_cv_lib_sjlj_exceptions=yes
+  elif grep _Unwind_Resume conftest.s >/dev/null 2>&1; then
+    libgo_cv_lib_sjlj_exceptions=no
+  fi])
+CFLAGS=$CFLAGS_hold
+rm -f conftest*
+])
+
+if test "$enable_sjlj_exceptions" = "auto"; then
+  enable_sjlj_exceptions=$libgo_cv_lib_sjlj_exceptions
+fi
+
+case $enable_sjlj_exceptions in
+yes)
+  AC_DEFINE(LIBGO_SJLJ_EXCEPTIONS, 1,
+	[Define if the C++ compiler is configured for setjmp/longjmp exceptions.])
+  ;;
+no)
+  ;;
+*)
+  AC_MSG_ERROR([unable to detect exception model])
+  ;;
+esac
+
 AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/user.h sys/utsname.h)
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 AC_CHECK_FUNCS(srandom random strsignal)
diff -r 51961799b012 libgo/runtime/go-unwind.c
--- a/libgo/runtime/go-unwind.c	Wed Feb 02 10:40:30 2011 -0800
+++ b/libgo/runtime/go-unwind.c	Wed Feb 02 17:48:18 2011 -0800
@@ -126,7 +126,7 @@ 
 
   hdr = (struct _Unwind_Exception *) __go_panic_defer->__exception;
 
-#ifdef _GLIBCXX_SJLJ_EXCEPTIONS
+#ifdef LIBGO_SJLJ_EXCEPTIONS
   _Unwind_SjLj_Resume_or_Rethrow (hdr);
 #else
 #if defined(_LIBUNWIND_STD_ABI)