libllvmForJSC shouldn't call exit(1) on report_fatal_error()
[WebKit-https.git] / Source / JavaScriptCore / llvm / InitializeLLVM.cpp
index b0c515f..cbfadb8 100644 (file)
 
 #if HAVE(LLVM)
 
+#include "LLVMAPI.h"
 #include <pthread.h>
 
 namespace JSC {
 
 static pthread_once_t initializeLLVMOnceKey = PTHREAD_ONCE_INIT;
 
+static NO_RETURN_DUE_TO_CRASH void llvmCrash(const char* reason)
+{
+    WTFLogAlways("LLVM failure: %s", reason);
+    CRASH();
+}
+
+static void initializeLLVMOnce()
+{
+    initializeLLVMImpl();
+    
+    llvm->InstallFatalErrorHandler(llvmCrash);
+}
+
 void initializeLLVM()
 {
-    pthread_once(&initializeLLVMOnceKey, initializeLLVMImpl);
+    pthread_once(&initializeLLVMOnceKey, initializeLLVMOnce);
 }
 
 } // namespace JSC