[llvm] r223805 - Adding a new option to CMake to disable C++ atexit on llvm-shlib.

Chris Bieneman beanz at apple.com
Tue Dec 9 10:49:56 PST 2014


Author: cbieneman
Date: Tue Dec  9 12:49:55 2014
New Revision: 223805

URL: http://llvm.org/viewvc/llvm-project?rev=223805&view=rev
Log:
Adding a new option to CMake to disable C++ atexit on llvm-shlib.

Summary:
This is desirable for WebKit and other clients of the llvm-shlib because C++ exit time destructors have a tendency to crash when invoked from multi-threaded applications.

Ideally this option will be temporary, because the ideal fix is to just not have exit time destructors.

Reviewers: chapuni, ributzka

Reviewed By: ributzka

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6572

Modified:
    llvm/trunk/CMakeLists.txt
    llvm/trunk/include/llvm/Config/config.h.cmake
    llvm/trunk/tools/llvm-shlib/libllvm.cpp

Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=223805&r1=223804&r2=223805&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Tue Dec  9 12:49:55 2014
@@ -324,6 +324,10 @@ option (LLVM_BUILD_EXTERNAL_COMPILER_RT
   "Build compiler-rt as an external project." OFF)
 
 option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" OFF)
+option(LLVM_DISABLE_LLVM_DYLIB_ATEXIT "Disable llvm-shlib's atexit destructors." ON)
+if(LLVM_DISABLE_LLVM_DYLIB_ATEXIT)
+  set(DISABLE_LLVM_DYLIB_ATEXIT 1)
+endif()
 
 # All options referred to from HandleLLVMOptions have to be specified
 # BEFORE this include, otherwise options will not be correctly set on

Modified: llvm/trunk/include/llvm/Config/config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=223805&r1=223804&r2=223805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Config/config.h.cmake (original)
+++ llvm/trunk/include/llvm/Config/config.h.cmake Tue Dec  9 12:49:55 2014
@@ -18,6 +18,9 @@
 /* Define to enable crash overrides */
 #cmakedefine ENABLE_CRASH_OVERRIDES
 
+/* Define to disable C++ atexit */
+#cmakedefine DISABLE_LLVM_DYLIB_ATEXIT
+
 /* Define if position independent code is enabled */
 #cmakedefine ENABLE_PIC
 

Modified: llvm/trunk/tools/llvm-shlib/libllvm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-shlib/libllvm.cpp?rev=223805&r1=223804&r2=223805&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-shlib/libllvm.cpp (original)
+++ llvm/trunk/tools/llvm-shlib/libllvm.cpp Tue Dec  9 12:49:55 2014
@@ -11,3 +11,10 @@
 // you can't define a target with no sources.
 //
 //===----------------------------------------------------------------------===//
+
+#include "llvm/Config/config.h"
+
+#if defined(DISABLE_LLVM_DYLIB_ATEXIT)
+extern "C" int __cxa_atexit();
+extern "C" int __cxa_atexit() { return 0; }
+#endif





More information about the llvm-commits mailing list