[libcxx-commits] [libcxxabi] r365944 - [libcxxabi] Don't process exceptions in cxa_handlers when they're disabled

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 12 12:10:59 PDT 2019


Author: phosek
Date: Fri Jul 12 12:10:59 2019
New Revision: 365944

URL: http://llvm.org/viewvc/llvm-project?rev=365944&view=rev
Log:
[libcxxabi] Don't process exceptions in cxa_handlers when they're disabled

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

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/src/cxa_default_handlers.cpp
    libcxxabi/trunk/src/cxa_handlers.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=365944&r1=365943&r2=365944&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Jul 12 12:10:59 2019
@@ -43,7 +43,9 @@ include(CMakeDependentOption)
 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)

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=365944&r1=365943&r2=365944&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Fri Jul 12 12:10:59 2019
@@ -25,6 +25,7 @@ static const char* cause = "uncaught";
 __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();
@@ -71,6 +72,7 @@ static void demangling_terminate_handler
                 abort_message("terminating with %s foreign exception", cause);
         }
     }
+#endif
     // Else just note that we're terminating
     abort_message("terminating");
 }

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=365944&r1=365943&r2=365944&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Fri Jul 12 12:10:59 2019
@@ -73,6 +73,7 @@ __attribute__((noreturn))
 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();
@@ -87,6 +88,7 @@ terminate() _NOEXCEPT
                 __terminate(exception_header->terminateHandler);
         }
     }
+#endif
     __terminate(get_terminate());
 }
 




More information about the libcxx-commits mailing list