When exceptions are disabled, avoid their processing altogether.
This avoids pulling in the depenency on demangler significantly
reducing binary size when statically linking against libc++abi
built without exception support.
Differential Revision: https://reviews.llvm.org/D64191
llvm-svn: 365944
include(HandleCompilerRT)
# Define options.
-option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON)
+option(LIBCXXABI_ENABLE_EXCEPTIONS
+ "Provide support for exceptions in the runtime.
+ When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON)
option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LIBCXXABI_ENABLE_PIC "Build Position-Independent Code, even in static library" ON)
__attribute__((noreturn))
static void demangling_terminate_handler()
{
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
// If there might be an uncaught exception
using namespace __cxxabiv1;
__cxa_eh_globals* globals = __cxa_get_globals_fast();
abort_message("terminating with %s foreign exception", cause);
}
}
+#endif
// Else just note that we're terminating
abort_message("terminating");
}
void
terminate() _NOEXCEPT
{
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
// If there might be an uncaught exception
using namespace __cxxabiv1;
__cxa_eh_globals* globals = __cxa_get_globals_fast();
__terminate(exception_header->terminateHandler);
}
}
+#endif
__terminate(get_terminate());
}