@@ -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)
@@ -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)