[conf] Add config variable to disable crash related overrides.

- We do some nasty things w.r.t. installing or overriding signal handlers in
   order to improve our crash recovery support or interaction with crash
   reporting software, and those things are not necessarily appropriate when
   LLVM is being linked into a client application that has its own ideas about
   how to do things. This gives those clients a way to disable that handling at
   build time.

 - Currently, the code this guards is all Apple specific, but other platforms
   might have the same concerns so I went for a more generic configure
   name. Someone who is more familiar with library embedding on Windows can
   handle choosing which of the Windows/Signals.inc behaviors might make sense
   to go under this flag.

 - This also fixes the proper autoconf'ing of ENABLE_BACKTRACES. The code
   expects it to be undefined when disabled, but the autoconf check was just
   defining it to 0.

llvm-svn: 189694
This commit is contained in:
Daniel Dunbar 2013-08-30 20:39:21 +00:00
parent 1b9b9ec464
commit eb6c708d92
6 changed files with 82 additions and 37 deletions

View File

@ -139,6 +139,11 @@ if(LLVM_ENABLE_BACKTRACES)
set(ENABLE_BACKTRACES 1) set(ENABLE_BACKTRACES 1)
endif() endif()
option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON)
if(LLVM_ENABLE_CRASH_OVERRIDES)
set(ENABLE_CRASH_OVERRIDES 1)
endif()
option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF) option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF)
set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so") set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h") set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")

View File

@ -800,20 +800,37 @@ esac
AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS, AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
[Define if timestamp information (e.g., __DATE__) is allowed]) [Define if timestamp information (e.g., __DATE__) is allowed])
dnl Enable embedding timestamp information into build. dnl Enable support for showing backtraces.
AC_ARG_ENABLE(backtraces, AS_HELP_STRING(
AC_ARG_ENABLE(backtraces, [--enable-backtraces],
AS_HELP_STRING([--enable-backtraces], [Enable embedding backtraces on crash (default is YES)]),
[Enable embedding backtraces on crash (default is YES)]),, [case "$enableval" in
enableval=default) yes) llvm_cv_enable_backtraces="yes" ;;
case "$enableval" in no) llvm_cv_enable_backtraces="no" ;;
yes) AC_SUBST(ENABLE_BACKTRACES,[1]) ;;
no) AC_SUBST(ENABLE_BACKTRACES,[0]) ;;
default) AC_SUBST(ENABLE_BACKTRACES,[1]) ;;
*) AC_MSG_ERROR([Invalid setting for --enable-backtraces. Use "yes" or "no"]) ;; *) AC_MSG_ERROR([Invalid setting for --enable-backtraces. Use "yes" or "no"]) ;;
esac esac],
AC_DEFINE_UNQUOTED([ENABLE_BACKTRACES],$ENABLE_BACKTRACES, llvm_cv_enable_backtraces="yes")
if test "$llvm_cv_enable_backtraces" = "yes" ; then
AC_DEFINE([ENABLE_BACKTRACES],[1],
[Define if you want backtraces on crash]) [Define if you want backtraces on crash])
fi
dnl Enable installing platform specific signal handling overrides, for improved
dnl CrashRecovery support or interaction with crash reporting software. This
dnl support may be inappropriate for some clients embedding LLVM as a library.
AC_ARG_ENABLE(crash-overrides, AS_HELP_STRING(
[--enable-crash-overrides],
[Enable crash handling overrides (default is YES)]),
[case "$enableval" in
yes) llvm_cv_enable_crash_overrides="yes" ;;
no) llvm_cv_enable_crash_overrides="no" ;;
*) AC_MSG_ERROR([Invalid setting for --enable-crash-overrides. Use "yes" or "no"]) ;;
esac],
llvm_cv_enable_crash_overrides="yes")
if test "$llvm_cv_enable_crash_overrides" = "yes" ; then
AC_DEFINE([ENABLE_CRASH_OVERRIDES],[1],
[Define to enable crash handling overrides])
fi
dnl Allow specific targets to be specified for building (or not) dnl Allow specific targets to be specified for building (or not)
TARGETS_TO_BUILD="" TARGETS_TO_BUILD=""

59
llvm/configure vendored
View File

@ -709,7 +709,6 @@ ENABLE_PIC
ENABLE_SHARED ENABLE_SHARED
ENABLE_EMBED_STDCXX ENABLE_EMBED_STDCXX
ENABLE_TIMESTAMPS ENABLE_TIMESTAMPS
ENABLE_BACKTRACES
TARGETS_TO_BUILD TARGETS_TO_BUILD
LLVM_ENUM_TARGETS LLVM_ENUM_TARGETS
LLVM_ENUM_ASM_PRINTERS LLVM_ENUM_ASM_PRINTERS
@ -1443,6 +1442,8 @@ Optional Features:
(default is YES) (default is YES)
--enable-backtraces Enable embedding backtraces on crash (default is --enable-backtraces Enable embedding backtraces on crash (default is
YES) YES)
--enable-crash-overrides
Enable crash handling overrides (default is YES)
--enable-targets Build specific host targets: all or --enable-targets Build specific host targets: all or
target1,target2,... Valid targets are: host, x86, target1,target2,... Valid targets are: host, x86,
x86_64, sparc, powerpc, arm, aarch64, mips, hexagon, x86_64, sparc, powerpc, arm, aarch64, mips, hexagon,
@ -5632,30 +5633,47 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
# Check whether --enable-backtraces was given. # Check whether --enable-backtraces was given.
if test "${enable_backtraces+set}" = set; then if test "${enable_backtraces+set}" = set; then
enableval=$enable_backtraces; enableval=$enable_backtraces; case "$enableval" in
else yes) llvm_cv_enable_backtraces="yes" ;;
enableval=default no) llvm_cv_enable_backtraces="no" ;;
fi
case "$enableval" in
yes) ENABLE_BACKTRACES=1
;;
no) ENABLE_BACKTRACES=0
;;
default) ENABLE_BACKTRACES=1
;;
*) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-backtraces. Use \"yes\" or \"no\"" >&5 *) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-backtraces. Use \"yes\" or \"no\"" >&5
echo "$as_me: error: Invalid setting for --enable-backtraces. Use \"yes\" or \"no\"" >&2;} echo "$as_me: error: Invalid setting for --enable-backtraces. Use \"yes\" or \"no\"" >&2;}
{ (exit 1); exit 1; }; } ;; { (exit 1); exit 1; }; } ;;
esac esac
else
llvm_cv_enable_backtraces="yes"
fi
cat >>confdefs.h <<_ACEOF if test "$llvm_cv_enable_backtraces" = "yes" ; then
#define ENABLE_BACKTRACES $ENABLE_BACKTRACES
cat >>confdefs.h <<\_ACEOF
#define ENABLE_BACKTRACES 1
_ACEOF _ACEOF
fi
# Check whether --enable-crash-overrides was given.
if test "${enable_crash_overrides+set}" = set; then
enableval=$enable_crash_overrides; case "$enableval" in
yes) llvm_cv_enable_crash_overrides="yes" ;;
no) llvm_cv_enable_crash_overrides="no" ;;
*) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-crash-overrides. Use \"yes\" or \"no\"" >&5
echo "$as_me: error: Invalid setting for --enable-crash-overrides. Use \"yes\" or \"no\"" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
else
llvm_cv_enable_crash_overrides="yes"
fi
if test "$llvm_cv_enable_crash_overrides" = "yes" ; then
cat >>confdefs.h <<\_ACEOF
#define ENABLE_CRASH_OVERRIDES 1
_ACEOF
fi
TARGETS_TO_BUILD="" TARGETS_TO_BUILD=""
# Check whether --enable-targets was given. # Check whether --enable-targets was given.
@ -10568,7 +10586,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 10571 "configure" #line 10589 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -23055,7 +23073,6 @@ ENABLE_PIC!$ENABLE_PIC$ac_delim
ENABLE_SHARED!$ENABLE_SHARED$ac_delim ENABLE_SHARED!$ENABLE_SHARED$ac_delim
ENABLE_EMBED_STDCXX!$ENABLE_EMBED_STDCXX$ac_delim ENABLE_EMBED_STDCXX!$ENABLE_EMBED_STDCXX$ac_delim
ENABLE_TIMESTAMPS!$ENABLE_TIMESTAMPS$ac_delim ENABLE_TIMESTAMPS!$ENABLE_TIMESTAMPS$ac_delim
ENABLE_BACKTRACES!$ENABLE_BACKTRACES$ac_delim
TARGETS_TO_BUILD!$TARGETS_TO_BUILD$ac_delim TARGETS_TO_BUILD!$TARGETS_TO_BUILD$ac_delim
LLVM_ENUM_TARGETS!$LLVM_ENUM_TARGETS$ac_delim LLVM_ENUM_TARGETS!$LLVM_ENUM_TARGETS$ac_delim
LLVM_ENUM_ASM_PRINTERS!$LLVM_ENUM_ASM_PRINTERS$ac_delim LLVM_ENUM_ASM_PRINTERS!$LLVM_ENUM_ASM_PRINTERS$ac_delim
@ -23142,6 +23159,7 @@ LLVM_MANDIR!$LLVM_MANDIR$ac_delim
LLVM_CONFIGTIME!$LLVM_CONFIGTIME$ac_delim LLVM_CONFIGTIME!$LLVM_CONFIGTIME$ac_delim
BINDINGS_TO_BUILD!$BINDINGS_TO_BUILD$ac_delim BINDINGS_TO_BUILD!$BINDINGS_TO_BUILD$ac_delim
ALL_BINDINGS!$ALL_BINDINGS$ac_delim ALL_BINDINGS!$ALL_BINDINGS$ac_delim
OCAML_LIBDIR!$OCAML_LIBDIR$ac_delim
_ACEOF _ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@ -23183,7 +23201,6 @@ _ACEOF
ac_delim='%!_!# ' ac_delim='%!_!# '
for ac_last_try in false false false false false :; do for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF cat >conf$$subs.sed <<_ACEOF
OCAML_LIBDIR!$OCAML_LIBDIR$ac_delim
ENABLE_VISIBILITY_INLINES_HIDDEN!$ENABLE_VISIBILITY_INLINES_HIDDEN$ac_delim ENABLE_VISIBILITY_INLINES_HIDDEN!$ENABLE_VISIBILITY_INLINES_HIDDEN$ac_delim
RPATH!$RPATH$ac_delim RPATH!$RPATH$ac_delim
RDYNAMIC!$RDYNAMIC$ac_delim RDYNAMIC!$RDYNAMIC$ac_delim
@ -23192,7 +23209,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF _ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 7; then if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 6; then
break break
elif $ac_last_try; then elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@ -21,6 +21,9 @@
/* Define if you want backtraces on crash */ /* Define if you want backtraces on crash */
#cmakedefine ENABLE_BACKTRACES #cmakedefine ENABLE_BACKTRACES
/* Define to enable crash overrides */
#cmakedefine ENABLE_CRASH_OVERRIDES
/* Define if position independent code is enabled */ /* Define if position independent code is enabled */
#cmakedefine ENABLE_PIC #cmakedefine ENABLE_PIC

View File

@ -21,6 +21,9 @@
/* Define if you want backtraces on crash */ /* Define if you want backtraces on crash */
#undef ENABLE_BACKTRACES #undef ENABLE_BACKTRACES
/* Define to enable crash handling overrides */
#undef ENABLE_CRASH_OVERRIDES
/* Define if position independent code is enabled */ /* Define if position independent code is enabled */
#undef ENABLE_PIC #undef ENABLE_PIC

View File

@ -333,7 +333,7 @@ static void PrintStackTraceSignalHandler(void *) {
void llvm::sys::PrintStackTraceOnErrorSignal() { void llvm::sys::PrintStackTraceOnErrorSignal() {
AddSignalHandler(PrintStackTraceSignalHandler, 0); AddSignalHandler(PrintStackTraceSignalHandler, 0);
#if defined(__APPLE__) #if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES)
// Environment variable to disable any kind of crash dialog. // Environment variable to disable any kind of crash dialog.
if (getenv("LLVM_DISABLE_CRASH_REPORT")) { if (getenv("LLVM_DISABLE_CRASH_REPORT")) {
mach_port_t self = mach_task_self(); mach_port_t self = mach_task_self();
@ -359,7 +359,7 @@ void llvm::sys::PrintStackTraceOnErrorSignal() {
// the same linkage unit by just defining our own versions of the assert handler // the same linkage unit by just defining our own versions of the assert handler
// and abort. // and abort.
#ifdef __APPLE__ #if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES)
#include <signal.h> #include <signal.h>
#include <pthread.h> #include <pthread.h>