On Tue, Oct 26, 2021 at 2:21 PM Thomas Munro <thomas.mu...@gmail.com> wrote:
> Here's one like that.  The previous message "Track LLVM 14 API
> changes" didn't seem too scalable so I added date and commit ID.

seawasp finally caught up with these LLVM changes and turned red.  I
retested the patch against this week's LLVM locally.  New version also
adds #include <new>, for the definition of std::new_handler, which g++
is now complaining about in llvmjit_error.cpp.

Since then, the LLVM 14 headers have started spewing deprecation
notices about LLVMBuildStructGEP, LLVMBuildLoad, LLVMBuildCall.  The
warnings say things like "Use LLVMBuildStructGEP2 instead to support
opaque pointers", and the -2 variants need a new argument that takes
an extra LLVMTypeRef argument, but I didn't look further...
From 961d9a150e38396142d1adab310147e3f172e8a9 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.mu...@gmail.com>
Date: Tue, 26 Oct 2021 14:03:59 +1300
Subject: [PATCH v2] Track LLVM 14 API changes, 2022-01-30

Tested with LLVM 13 and LLVM 14 at commit 8d8fce87bbd5.  Also add
missing #include <new>.

Reviewed-by: Andres Freund <and...@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2B3Ac3He9_SpJcxeiiVknbcES1tbZEkH9sRBdJFGj8K5Q%40mail.gmail.com
---
 src/backend/jit/llvm/llvmjit_error.cpp | 35 ++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
index 3ea7dcd3d1..542425dc62 100644
--- a/src/backend/jit/llvm/llvmjit_error.cpp
+++ b/src/backend/jit/llvm/llvmjit_error.cpp
@@ -23,15 +23,22 @@ extern "C"
 
 #include "jit/llvmjit.h"
 
+#include <new>
 
 static int fatal_new_handler_depth = 0;
 static std::new_handler old_new_handler = NULL;
 
 static void fatal_system_new_handler(void);
 #if LLVM_VERSION_MAJOR > 4
+static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
+#if LLVM_VERSION_MAJOR < 14
 static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
 #endif
+#endif
+static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
+#if LLVM_VERSION_MAJOR < 14
 static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
+#endif
 
 
 /*
@@ -129,23 +136,41 @@ fatal_system_new_handler(void)
 #if LLVM_VERSION_MAJOR > 4
 static void
 fatal_llvm_new_handler(void *user_data,
-					   const std::string& reason,
+					   const char *reason,
 					   bool gen_crash_diag)
 {
 	ereport(FATAL,
 			(errcode(ERRCODE_OUT_OF_MEMORY),
 			 errmsg("out of memory"),
-			 errdetail("While in LLVM: %s", reason.c_str())));
+			 errdetail("While in LLVM: %s", reason)));
+}
+#if LLVM_VERSION_MAJOR < 14
+static void
+fatal_llvm_new_handler(void *user_data,
+					   const std::string& reason,
+					   bool gen_crash_diag)
+{
+	fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
 }
 #endif
+#endif
 
 static void
 fatal_llvm_error_handler(void *user_data,
-						 const std::string& reason,
+						 const char *reason,
 						 bool gen_crash_diag)
 {
 	ereport(FATAL,
 			(errcode(ERRCODE_OUT_OF_MEMORY),
-			 errmsg("fatal llvm error: %s",
-					reason.c_str())));
+			 errmsg("fatal llvm error: %s", reason)));
 }
+
+#if LLVM_VERSION_MAJOR < 14
+static void
+fatal_llvm_error_handler(void *user_data,
+						 const std::string& reason,
+						 bool gen_crash_diag)
+{
+	fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag);
+}
+#endif
-- 
2.30.2

Reply via email to