Index: libcxxabi/trunk/CMakeLists.txt =================================================================== --- libcxxabi/trunk/CMakeLists.txt +++ libcxxabi/trunk/CMakeLists.txt @@ -433,6 +433,10 @@ add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER=1) endif() +if (LIBCXXABI_SILENT_TERMINATE) + add_definitions(-DLIBCXXABI_SILENT_TERMINATE=1) +endif() + string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}") Index: libcxxabi/trunk/src/config.h =================================================================== --- libcxxabi/trunk/src/config.h +++ libcxxabi/trunk/src/config.h @@ -23,4 +23,11 @@ # define LIBCXXABI_BAREMETAL 0 #endif +// The default terminate handler attempts to demangle uncaught exceptions, which +// causes extra I/O and demangling code to be pulled in. +// Set this to make the terminate handler default to a silent alternative. +#ifndef LIBCXXABI_SILENT_TERMINATE +# define LIBCXXABI_SILENT_TERMINATE 0 +#endif + #endif // LIBCXXABI_CONFIG_H Index: libcxxabi/trunk/src/cxa_default_handlers.cpp =================================================================== --- libcxxabi/trunk/src/cxa_default_handlers.cpp +++ libcxxabi/trunk/src/cxa_default_handlers.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "abort_message.h" #include "config.h" // For __sync_swap #include "cxxabi.h" @@ -22,7 +23,7 @@ static const char* cause = "uncaught"; __attribute__((noreturn)) -static void default_terminate_handler() +static void demangling_terminate_handler() { // If there might be an uncaught exception using namespace __cxxabiv1; @@ -78,12 +79,19 @@ } __attribute__((noreturn)) -static void default_unexpected_handler() +static void demangling_unexpected_handler() { cause = "unexpected"; std::terminate(); } +#if !LIBCXXABI_SILENT_TERMINATE +static std::terminate_handler default_terminate_handler = demangling_terminate_handler; +static std::terminate_handler default_unexpected_handler = demangling_unexpected_handler; +#else +static std::terminate_handler default_terminate_handler = std::abort; +static std::terminate_handler default_unexpected_handler = std::abort; +#endif // // Global variables that hold the pointers to the current handler