f37: Fix builds against LLVM 15
Backport upstream fix to fix builds against LLVM 15 Also add missing BuildRequires for perl FindBin module
This commit is contained in:
parent
3129912180
commit
b6b1e57050
|
@ -0,0 +1,192 @@
|
||||||
|
From d033f8f8bea9c7b5c4ae43a95b569ceccdaddd7a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thomas Munro <tmunro@postgresql.org>
|
||||||
|
Date: Wed, 19 Oct 2022 22:32:14 +1300
|
||||||
|
Subject: [PATCH] Track LLVM 15 changes.
|
||||||
|
|
||||||
|
Per https://llvm.org/docs/OpaquePointers.html, support for non-opaque
|
||||||
|
pointers still exists and we can request that on our context. We have
|
||||||
|
until LLVM 16 to move to opaque pointers, a much larger change.
|
||||||
|
|
||||||
|
Back-patch to 11, where LLVM support arrived.
|
||||||
|
|
||||||
|
Author: Thomas Munro <thomas.munro@gmail.com>
|
||||||
|
Author: Andres Freund <andres@anarazel.de>
|
||||||
|
Discussion: https://postgr.es/m/CAMHz58Sf_xncdyqsekoVsNeKcruKootLtVH6cYXVhhUR1oKPCg%40mail.gmail.com
|
||||||
|
---
|
||||||
|
configure | 89 +++++++++++++++++++++++++
|
||||||
|
configure.ac | 3 +
|
||||||
|
src/backend/jit/llvm/llvmjit.c | 18 +++++
|
||||||
|
src/backend/jit/llvm/llvmjit_inline.cpp | 1 +
|
||||||
|
4 files changed, 111 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 57ec071cf9bd..a15c2253d58c 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -7259,6 +7259,95 @@ if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes";
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Xclang -no-opaque-pointers, for BITCODE_CFLAGS" >&5
|
||||||
|
+$as_echo_n "checking whether ${CLANG} supports -Xclang -no-opaque-pointers, for BITCODE_CFLAGS... " >&6; }
|
||||||
|
+if ${pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers+:} false; then :
|
||||||
|
+ $as_echo_n "(cached) " >&6
|
||||||
|
+else
|
||||||
|
+ pgac_save_CFLAGS=$CFLAGS
|
||||||
|
+pgac_save_CC=$CC
|
||||||
|
+CC=${CLANG}
|
||||||
|
+CFLAGS="${BITCODE_CFLAGS} -Xclang -no-opaque-pointers"
|
||||||
|
+ac_save_c_werror_flag=$ac_c_werror_flag
|
||||||
|
+ac_c_werror_flag=yes
|
||||||
|
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
+/* end confdefs.h. */
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+main ()
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ ;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+_ACEOF
|
||||||
|
+if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
+ pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers=yes
|
||||||
|
+else
|
||||||
|
+ pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers=no
|
||||||
|
+fi
|
||||||
|
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
+ac_c_werror_flag=$ac_save_c_werror_flag
|
||||||
|
+CFLAGS="$pgac_save_CFLAGS"
|
||||||
|
+CC="$pgac_save_CC"
|
||||||
|
+fi
|
||||||
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" >&5
|
||||||
|
+$as_echo "$pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" >&6; }
|
||||||
|
+if test x"$pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" = x"yes"; then
|
||||||
|
+ BITCODE_CFLAGS="${BITCODE_CFLAGS} -Xclang -no-opaque-pointers"
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANGXX} supports -Xclang -no-opaque-pointers, for BITCODE_CXXFLAGS" >&5
|
||||||
|
+$as_echo_n "checking whether ${CLANGXX} supports -Xclang -no-opaque-pointers, for BITCODE_CXXFLAGS... " >&6; }
|
||||||
|
+if ${pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers+:} false; then :
|
||||||
|
+ $as_echo_n "(cached) " >&6
|
||||||
|
+else
|
||||||
|
+ pgac_save_CXXFLAGS=$CXXFLAGS
|
||||||
|
+pgac_save_CXX=$CXX
|
||||||
|
+CXX=${CLANGXX}
|
||||||
|
+CXXFLAGS="${BITCODE_CXXFLAGS} -Xclang -no-opaque-pointers"
|
||||||
|
+ac_save_cxx_werror_flag=$ac_cxx_werror_flag
|
||||||
|
+ac_cxx_werror_flag=yes
|
||||||
|
+ac_ext=cpp
|
||||||
|
+ac_cpp='$CXXCPP $CPPFLAGS'
|
||||||
|
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||||
|
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||||
|
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||||
|
+
|
||||||
|
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
+/* end confdefs.h. */
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+main ()
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ ;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+_ACEOF
|
||||||
|
+if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||||
|
+ pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers=yes
|
||||||
|
+else
|
||||||
|
+ pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers=no
|
||||||
|
+fi
|
||||||
|
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
+ac_ext=c
|
||||||
|
+ac_cpp='$CPP $CPPFLAGS'
|
||||||
|
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||||
|
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||||
|
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||||
|
+
|
||||||
|
+ac_cxx_werror_flag=$ac_save_cxx_werror_flag
|
||||||
|
+CXXFLAGS="$pgac_save_CXXFLAGS"
|
||||||
|
+CXX="$pgac_save_CXX"
|
||||||
|
+fi
|
||||||
|
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" >&5
|
||||||
|
+$as_echo "$pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" >&6; }
|
||||||
|
+if test x"$pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" = x"yes"; then
|
||||||
|
+ BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -Xclang -no-opaque-pointers"
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+
|
||||||
|
NOT_THE_CFLAGS=""
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
|
||||||
|
$as_echo_n "checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index 227bc896b69c..6d13ae588892 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -600,6 +600,9 @@ if test "$with_llvm" = yes ; then
|
||||||
|
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
|
||||||
|
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
|
||||||
|
|
||||||
|
+ PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-Xclang -no-opaque-pointers])
|
||||||
|
+ PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-Xclang -no-opaque-pointers])
|
||||||
|
+
|
||||||
|
NOT_THE_CFLAGS=""
|
||||||
|
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wunused-command-line-argument])
|
||||||
|
if test -n "$NOT_THE_CFLAGS"; then
|
||||||
|
diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
|
||||||
|
index fb294495737c..199fff4f773c 100644
|
||||||
|
--- a/src/backend/jit/llvm/llvmjit.c
|
||||||
|
+++ b/src/backend/jit/llvm/llvmjit.c
|
||||||
|
@@ -798,6 +798,16 @@ llvm_session_initialize(void)
|
||||||
|
LLVMInitializeNativeAsmPrinter();
|
||||||
|
LLVMInitializeNativeAsmParser();
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * When targeting an LLVM version with opaque pointers enabled by
|
||||||
|
+ * default, turn them off for the context we build our code in. We don't
|
||||||
|
+ * need to do so for other contexts (e.g. llvm_ts_context). Once the IR is
|
||||||
|
+ * generated, it carries the necessary information.
|
||||||
|
+ */
|
||||||
|
+#if LLVM_VERSION_MAJOR > 14
|
||||||
|
+ LLVMContextSetOpaquePointers(LLVMGetGlobalContext(), false);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Synchronize types early, as that also includes inferring the target
|
||||||
|
* triple.
|
||||||
|
@@ -1112,7 +1122,11 @@ llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
|
||||||
|
LLVMOrcJITDylibRef JD, LLVMOrcJITDylibLookupFlags JDLookupFlags,
|
||||||
|
LLVMOrcCLookupSet LookupSet, size_t LookupSetSize)
|
||||||
|
{
|
||||||
|
+#if LLVM_VERSION_MAJOR > 14
|
||||||
|
+ LLVMOrcCSymbolMapPairs symbols = palloc0(sizeof(LLVMOrcCSymbolMapPair) * LookupSetSize);
|
||||||
|
+#else
|
||||||
|
LLVMOrcCSymbolMapPairs symbols = palloc0(sizeof(LLVMJITCSymbolMapPair) * LookupSetSize);
|
||||||
|
+#endif
|
||||||
|
LLVMErrorRef error;
|
||||||
|
LLVMOrcMaterializationUnitRef mu;
|
||||||
|
|
||||||
|
@@ -1230,7 +1244,11 @@ llvm_create_jit_instance(LLVMTargetMachineRef tm)
|
||||||
|
* Symbol resolution support for "special" functions, e.g. a call into an
|
||||||
|
* SQL callable function.
|
||||||
|
*/
|
||||||
|
+#if LLVM_VERSION_MAJOR > 14
|
||||||
|
+ ref_gen = LLVMOrcCreateCustomCAPIDefinitionGenerator(llvm_resolve_symbols, NULL, NULL);
|
||||||
|
+#else
|
||||||
|
ref_gen = LLVMOrcCreateCustomCAPIDefinitionGenerator(llvm_resolve_symbols, NULL);
|
||||||
|
+#endif
|
||||||
|
LLVMOrcJITDylibAddGenerator(LLVMOrcLLJITGetMainJITDylib(lljit), ref_gen);
|
||||||
|
|
||||||
|
return lljit;
|
||||||
|
diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
|
||||||
|
index 9bb4b672a736..774d9e8b66dc 100644
|
||||||
|
--- a/src/backend/jit/llvm/llvmjit_inline.cpp
|
||||||
|
+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
|
||||||
|
@@ -62,6 +62,7 @@ extern "C"
|
||||||
|
#include <llvm/IR/ModuleSummaryIndex.h>
|
||||||
|
#include <llvm/Linker/IRMover.h>
|
||||||
|
#include <llvm/Support/ManagedStatic.h>
|
||||||
|
+#include <llvm/Support/MemoryBuffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
|
@ -65,7 +65,7 @@ Summary: PostgreSQL client programs
|
||||||
Name: postgresql
|
Name: postgresql
|
||||||
%global majorversion 14
|
%global majorversion 14
|
||||||
Version: %{majorversion}.3
|
Version: %{majorversion}.3
|
||||||
Release: 8%{?dist}
|
Release: 9%{?dist}
|
||||||
|
|
||||||
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
|
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
|
||||||
# recognizes it as an independent license, so we do as well.
|
# recognizes it as an independent license, so we do as well.
|
||||||
|
@ -122,6 +122,8 @@ Patch14: postgresql-pgcrypto-openssl3-tests.patch
|
||||||
Patch15: postgresql-SPI-s-handling-of-errors-during-transaction-comm.patch
|
Patch15: postgresql-SPI-s-handling-of-errors-during-transaction-comm.patch
|
||||||
# Fix compatibility with Perl 5.36
|
# Fix compatibility with Perl 5.36
|
||||||
Patch16: postgresql-pl-perl-test-case.patch
|
Patch16: postgresql-pl-perl-test-case.patch
|
||||||
|
# Fix compatibility with LLVM 15
|
||||||
|
Patch17: postgresql-llvm-15-compat.patch
|
||||||
|
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
BuildRequires: lz4-devel
|
BuildRequires: lz4-devel
|
||||||
|
@ -129,6 +131,7 @@ BuildRequires: gcc
|
||||||
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
|
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
|
||||||
BuildRequires: perl(ExtUtils::Embed), perl-devel
|
BuildRequires: perl(ExtUtils::Embed), perl-devel
|
||||||
BuildRequires: perl(Opcode)
|
BuildRequires: perl(Opcode)
|
||||||
|
BuildRequires: perl(FindBin)
|
||||||
%if 0%{?fedora} || 0%{?rhel} > 7
|
%if 0%{?fedora} || 0%{?rhel} > 7
|
||||||
BuildRequires: perl-generators
|
BuildRequires: perl-generators
|
||||||
%endif
|
%endif
|
||||||
|
@ -442,6 +445,7 @@ goal of accelerating analytics queries.
|
||||||
%patch14 -p1
|
%patch14 -p1
|
||||||
%patch15 -p1
|
%patch15 -p1
|
||||||
%patch16 -p1
|
%patch16 -p1
|
||||||
|
%patch17 -p1
|
||||||
# We used to run autoconf here, but there's no longer any real need to,
|
# We used to run autoconf here, but there's no longer any real need to,
|
||||||
# since Postgres ships with a reasonably modern configure script.
|
# since Postgres ships with a reasonably modern configure script.
|
||||||
|
|
||||||
|
@ -1262,6 +1266,10 @@ make -C postgresql-setup-%{setup_version} check
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Oct 20 2022 Daan De Meyer <daan.j.demeyer@gmail.com> - 14.3.11
|
||||||
|
- Backport commit to fix builds with LLVM 15
|
||||||
|
- Add missing perl FindBin BuildRequires
|
||||||
|
|
||||||
* Mon Aug 01 2022 Frantisek Zatloukal <fzatlouk@redhat.com> - 14.3-8
|
* Mon Aug 01 2022 Frantisek Zatloukal <fzatlouk@redhat.com> - 14.3-8
|
||||||
- Rebuilt for ICU 71.1
|
- Rebuilt for ICU 71.1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue