On Tue, Oct 26, 2021 at 1:52 PM Andres Freund <and...@anarazel.de> wrote: > On 2021-10-26 13:39:53 +1300, Thomas Munro wrote: > > According to my crystal ball, seawasp will shortly break again[1][2] > > and the attached patch will fix it. > > That feels lot more convincing though. Based on past experience it's not hard > to believe that the compile-time impact of the include the use of std::string > forces into a lot of places is pretty significant... > > Could we make old case a wrapper around the new case that just passes on the > error as a const char *? That should be more maintainable long-term, because > there's only one copy of the body?
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.
From 575ea753e29424cb1b8ee4fc399284e5b6930a4a 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] Track LLVM 14 API changes, 2021-10-25. Tested with LLVM 13 and LLVM 14 at commit dbab339ea44e. 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 | 34 ++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp index daefb3e1fd..bfa19468a6 100644 --- a/src/backend/jit/llvm/llvmjit_error.cpp +++ b/src/backend/jit/llvm/llvmjit_error.cpp @@ -29,9 +29,15 @@ 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 +135,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