Index: llvm/trunk/CMakeLists.txt =================================================================== --- llvm/trunk/CMakeLists.txt +++ llvm/trunk/CMakeLists.txt @@ -324,6 +324,10 @@ "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 Index: llvm/trunk/include/llvm/Config/config.h.cmake =================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake +++ llvm/trunk/include/llvm/Config/config.h.cmake @@ -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 Index: llvm/trunk/tools/llvm-shlib/libllvm.cpp =================================================================== --- llvm/trunk/tools/llvm-shlib/libllvm.cpp +++ llvm/trunk/tools/llvm-shlib/libllvm.cpp @@ -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