Fix wrong configure test for abi::__forced_unwind in previous commit.

The previous commit was accidental and contained an initial version of the
patch which didn't test for NPTL abi::__forced_unwind correctly and just
tested whether cxxabi.h header was available.

Tighten the check to work on the other systems and check for __forced_unwind
existence itself.

Also check for cxxabi.h before testing for __cxa_demangle as there is no need
to try to compile another test program if we already know that this entire
header is unavailable anyhow.

See #14626.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2012-09-20 23:12:28 +00:00
parent e02ea2030c
commit 89b3361ec2
4 changed files with 109 additions and 25 deletions

69
configure vendored
View File

@ -30474,27 +30474,28 @@ $as_echo "$wx_cv_func_backtrace" >&6; }
$as_echo "$as_me: WARNING: backtrace() is not available, wxStackWalker will not be available" >&2;}
wxUSE_STACKWALKER=no
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cxa_demangle() in <cxxabi.h>" >&5
if test "$ac_cv_header_cxxabi_h" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __cxa_demangle() in <cxxabi.h>" >&5
$as_echo_n "checking for __cxa_demangle() in <cxxabi.h>... " >&6; }
if ${wx_cv_func_cxa_demangle+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_ext=cpp
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <cxxabi.h>
int
main ()
{
int rc;
__cxxabiv1::__cxa_demangle("foo", 0, 0, &rc);
int rc;
__cxxabiv1::__cxa_demangle("foo", 0, 0, &rc);
;
return 0;
@ -30508,7 +30509,7 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
ac_ext=c
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@ -30519,6 +30520,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_func_cxa_demangle" >&5
$as_echo "$wx_cv_func_cxa_demangle" >&6; }
else
wx_cv_func_cxa_demangle=no
fi
if test "$wx_cv_func_cxa_demangle" = "yes"; then
$as_echo "#define HAVE_CXA_DEMANGLE 1" >>confdefs.h
@ -32385,6 +32389,59 @@ $as_echo "yes, it works" >&6; }
fi
fi
if test "$ac_cv_header_cxxabi_h" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for abi::__forced_unwind() in <cxxabi.h>" >&5
$as_echo_n "checking for abi::__forced_unwind() in <cxxabi.h>... " >&6; }
if ${wx_cv_type_abi_forced_unwind+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <cxxabi.h>
int
main ()
{
void foo(abi::__forced_unwind&);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
wx_cv_type_abi_forced_unwind=yes
else
wx_cv_type_abi_forced_unwind=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_type_abi_forced_unwind" >&5
$as_echo "$wx_cv_type_abi_forced_unwind" >&6; }
else
wx_cv_type_abi_forced_unwind=no
fi
if test "$wx_cv_type_abi_forced_unwind" = "yes"; then
$as_echo "#define HAVE_ABI_FORCEDUNWIND 1" >>confdefs.h
fi
fi
else

View File

@ -4387,20 +4387,24 @@ if test "$wxUSE_STACKWALKER" = "yes" -a "$wxUSE_UNIX" = "yes"; then
AC_MSG_WARN([backtrace() is not available, wxStackWalker will not be available])
wxUSE_STACKWALKER=no
else
AC_CACHE_CHECK([for __cxa_demangle() in <cxxabi.h>], wx_cv_func_cxa_demangle,
[
AC_LANG_PUSH(C++)
AC_TRY_LINK([#include <cxxabi.h>],
[
int rc;
__cxxabiv1::__cxa_demangle("foo", 0, 0, &rc);
],
wx_cv_func_cxa_demangle=yes,
wx_cv_func_cxa_demangle=no
)
AC_LANG_POP()
]
)
if test "$ac_cv_header_cxxabi_h" = "yes"; then
AC_CACHE_CHECK([for __cxa_demangle() in <cxxabi.h>], wx_cv_func_cxa_demangle,
[
AC_LANG_PUSH(C++)
AC_TRY_LINK([#include <cxxabi.h>],
[
int rc;
__cxxabiv1::__cxa_demangle("foo", 0, 0, &rc);
],
wx_cv_func_cxa_demangle=yes,
wx_cv_func_cxa_demangle=no
)
AC_LANG_POP()
]
)
else
wx_cv_func_cxa_demangle=no
fi
if test "$wx_cv_func_cxa_demangle" = "yes"; then
AC_DEFINE(HAVE_CXA_DEMANGLE)
@ -5095,6 +5099,29 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then
AC_DEFINE(HAVE___THREAD_KEYWORD)
fi
fi
if test "$ac_cv_header_cxxabi_h" = "yes"; then
AC_CACHE_CHECK([for abi::__forced_unwind() in <cxxabi.h>],
wx_cv_type_abi_forced_unwind,
[
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([#include <cxxabi.h>],
[
void foo(abi::__forced_unwind&);
],
wx_cv_type_abi_forced_unwind=yes,
wx_cv_type_abi_forced_unwind=no
)
AC_LANG_POP()
]
)
else
wx_cv_type_abi_forced_unwind=no
fi
if test "$wx_cv_type_abi_forced_unwind" = "yes"; then
AC_DEFINE(HAVE_ABI_FORCEDUNWIND)
fi
fi
dnl from if !MSW

View File

@ -1225,8 +1225,8 @@
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have <cxxabi.h> header file. */
#undef HAVE_CXXABI_H
/* Define if you have abi::__forced_unwind in your <cxxabi.h>. */
#undef HAVE_ABI_FORCEDUNWIND
/* Define if fdopen is available. */
#undef HAVE_FDOPEN

View File

@ -54,7 +54,7 @@
#include <thread.h>
#endif
#ifdef HAVE_CXXABI_H
#ifdef HAVE_ABI_FORCEDUNWIND
#include <cxxabi.h>
#endif
@ -861,7 +861,7 @@ void *wxThreadInternal::PthreadStart(wxThread *thread)
wxT("Thread %p Entry() returned %lu."),
THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode));
}
#ifdef HAVE_CXXABI_H
#ifdef HAVE_ABI_FORCEDUNWIND
// When using common C++ ABI under Linux we must always rethrow this
// special exception used to unwind the stack when the thread was
// cancelled, otherwise the thread library would simply terminate the
@ -872,7 +872,7 @@ void *wxThreadInternal::PthreadStart(wxThread *thread)
pthread->SetState(STATE_EXITED);
throw;
}
#endif // HAVE_CXXABI_H
#endif // HAVE_ABI_FORCEDUNWIND
wxCATCH_ALL( wxTheApp->OnUnhandledException(); )
{