rebuilt with llvm 14.0.3 [release 14.2-2mamba;Sun May 01 2022]

This commit is contained in:
Silvan Calarco 2024-01-06 10:27:02 +01:00
parent ca0060eaa2
commit a6d5b2881f
2 changed files with 161 additions and 1 deletions

View File

@ -0,0 +1,154 @@
From 5610411ac7b7d86b781aaaeed7f02b0e1005f8bb Mon Sep 17 00:00:00 2001
From: Thomas Munro <tmunro@postgresql.org>
Date: Wed, 16 Mar 2022 11:35:00 +1300
Subject: [PATCH] Back-patch LLVM 14 API changes.
Since LLVM 14 has stopped changing and is about to be released,
back-patch the following changes from the master branch:
e6a7600202105919bffd62b3dfd941f4a94e082b
807fee1a39de6bb8184082012e643951abb9ad1d
a56e7b66010f330782243de9e25ac2a6596be0e1
Back-patch to 11, where LLVM JIT support came in.
---
src/backend/jit/llvm/Makefile | 6 +++++
src/backend/jit/llvm/llvmjit_error.cpp | 35 +++++++++++++++++++++----
src/backend/jit/llvm/llvmjit_inline.cpp | 12 ++++++++-
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 0268bd46d5..2da122a391 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -22,6 +22,12 @@ endif
PGFILEDESC = "llvmjit - JIT using LLVM"
NAME = llvmjit
+# LLVM 14 produces deprecation warnings. We'll need to make some changes
+# before the relevant functions are removed, but for now silence the warnings.
+ifeq ($(GCC), yes)
+LLVM_CFLAGS += -Wno-deprecated-declarations
+endif
+
# All files in this directory use LLVM.
CFLAGS += $(LLVM_CFLAGS)
CXXFLAGS += $(LLVM_CXXFLAGS)
diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
index 7c8f3252e2..2182a03c91 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
diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
index 40b18d9a0e..01168cab41 100644
--- a/src/backend/jit/llvm/llvmjit_inline.cpp
+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
@@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F,
if (F.materialize())
elog(FATAL, "failed to materialize metadata");
- if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline))
+#if LLVM_VERSION_MAJOR < 14
+#define hasFnAttr hasFnAttribute
+#endif
+
+ if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline))
{
ilog(DEBUG1, "ineligibile to import %s due to noinline",
F.getName().data());
@@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
llvm::Function *AF;
llvm::BasicBlock *BB;
llvm::CallInst *fwdcall;
+#if LLVM_VERSION_MAJOR < 14
llvm::Attribute inlineAttribute;
+#endif
AF = llvm::Function::Create(F->getFunctionType(),
LinkageTypes::AvailableExternallyLinkage,
@@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
Builder.SetInsertPoint(BB);
fwdcall = Builder.CreateCall(F, &*AF->arg_begin());
+#if LLVM_VERSION_MAJOR < 14
inlineAttribute = llvm::Attribute::get(Context,
llvm::Attribute::AlwaysInline);
fwdcall->addAttribute(~0U, inlineAttribute);
+#else
+ fwdcall->addFnAttr(llvm::Attribute::AlwaysInline);
+#endif
Builder.CreateRet(fwdcall);
return AF;
--
2.30.2

View File

@ -4,7 +4,7 @@
Name: postgresql Name: postgresql
Version: 14.2 Version: 14.2
Release: 1mamba Release: 2mamba
Summary: An object-relational database management system (ORDBMS) Summary: An object-relational database management system (ORDBMS)
Group: Applications/Databases Group: Applications/Databases
Vendor: openmamba Vendor: openmamba
@ -16,6 +16,7 @@ Source1: postgresql-initscript
Source2: postgresql.service Source2: postgresql.service
Source3: postgresql.tmpfiles Source3: postgresql.tmpfiles
Patch0: postgresql-13.1-run-socket.patch Patch0: postgresql-13.1-run-socket.patch
Patch1: postgresql-14.2-llvm-14.0.3.patch
License: BSD License: BSD
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel BuildRequires: glibc-devel
@ -38,6 +39,7 @@ BuildRequires: libxslt-devel
BuildRequires: libz-devel BuildRequires: libz-devel
## AUTOBUILDREQ-END ## AUTOBUILDREQ-END
BuildRequires: flex BuildRequires: flex
BuildRequires: libllvm-devel >= 14.0.3
Requires(pre): /usr/sbin/groupadd Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd Requires(pre): /usr/sbin/useradd
%systemd_requires %systemd_requires
@ -128,6 +130,7 @@ The postgresql-docs package includes some additional documentation for PostgreSQ
%prep %prep
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1 -b .llvm-14.0.3
%build %build
%configure \ %configure \
@ -357,6 +360,9 @@ find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \;
%{_libdir}/postgresql/tutorial/* %{_libdir}/postgresql/tutorial/*
%changelog %changelog
* Sun May 01 2022 Silvan Calarco <silvan.calarco@mambasoft.it> 14.2-2mamba
- rebuilt with llvm 14.0.3
* Fri Feb 11 2022 Automatic Build System <autodist@mambasoft.it> 14.2-1mamba * Fri Feb 11 2022 Automatic Build System <autodist@mambasoft.it> 14.2-1mamba
- automatic version update by autodist - automatic version update by autodist