From 8d03cad157e512726d1513e92dc8109035b1aaec Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:45:32 +0200 Subject: [PATCH] LLVM: Install error reporting handler --- Utilities/JITLLVM.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Utilities/JITLLVM.cpp b/Utilities/JITLLVM.cpp index f93a46645d..1a9c9e7052 100644 --- a/Utilities/JITLLVM.cpp +++ b/Utilities/JITLLVM.cpp @@ -565,6 +565,18 @@ jit_compiler::jit_compiler(const std::unordered_map& _link, co : m_context(new llvm::LLVMContext) , m_cpu(cpu(_cpu)) { + static const bool s_install_llvm_error_handler = []() + { + llvm::remove_fatal_error_handler(); + llvm::install_fatal_error_handler([](void*, const char* msg, bool) + { + const std::string_view out = msg ? msg : ""; + fmt::throw_exception("LLVM Emergency Exit Invoked: '%s'", out); + }, nullptr); + + return true; + }(); + std::string result; auto null_mod = std::make_unique ("null_", *m_context);