Merge ~ahasenack/ubuntu/+source/postgresql-14:jammy-postgresql-llvm14 into ubuntu/+source/postgresql-14:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Merged at revision: bcfd9ca66812192f09d17d1ea86f5210e7edbc59
Proposed branch: ~ahasenack/ubuntu/+source/postgresql-14:jammy-postgresql-llvm14
Merge into: ubuntu/+source/postgresql-14:ubuntu/devel
Diff against target: 198 lines (+164/-1)
4 files modified
debian/changelog (+6/-0)
debian/control (+2/-1)
debian/patches/llvm14-support.patch (+155/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Bryce Harrington (community) Approve
Canonical Server Pending
Review via email: mp+417695@code.launchpad.net

Description of the change

Fix FTBFS introduced when jammy got llvm-14. Previous jammy postgresql build was using llvm-13.

Thanks Christian for finding the upstream patch for this. I did a local test build and it worked. I created a bileto ticket[1], but it will be a while, and I don't know if bileto will even trigger tests, but at least we get the build in all arches.

So while that builds, let's have this MP up :)

1. https://bileto.ubuntu.com/#/ticket/4818

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

LGTM, not a super deep review but general approach looks good, and the patch checks out.

I've queued up tests in case they don't run via bileto:

$ lp-test-ppa ppa:ci-train-ppa-service/4818 --release jammy --showpass
Tests for PPA 4818
---- ---- ---- ----
Release: jammy
Sources:
  SRC: postgresql-14 @ 14.2-1ubuntu1~ppa1 - Published
Triggers on published Sources:
         postgresql-14 @ amd64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @amd64 ♻️ Trigger all proposed @amd64 ♻️ 💍
         postgresql-14 @ s390x for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @s390x ♻️ Trigger all proposed @s390x ♻️ 💍
         postgresql-14 @ ppc64el for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @ppc64el ♻️ Trigger all proposed @ppc64el ♻️ 💍
         postgresql-14 @ arm64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @arm64 ♻️ Trigger all proposed @arm64 ♻️ 💍
         postgresql-14 @ armhf for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @armhf ♻️ Trigger all proposed @armhf ♻️ 💍
         postgresql-14 @ riscv64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @riscv64 ♻️ Trigger all proposed @riscv64 ♻️ 💍
Results from https://autopkgtest.ubuntu.com/results/autopkgtest-jammy-ci-train-ppa-service-4818/?format=plain:
    No results published yet
Running:
    time pkg release arch ppa trigger
    0:02:50 postgresql-14 jammy arm64 ci-train-ppa-service/4818 postgresql-14/14.2-1ubuntu1~ppa1
    0:07:10 postgresql-14 jammy armhf ci-train-ppa-service/4818 postgresql-14/14.2-1ubuntu1~ppa1
    0:09:00 postgresql-14 jammy s390x ci-train-ppa-service/4818 postgresql-14/14.2-1ubuntu1~ppa1
    0:09:50 postgresql-14 jammy amd64 ci-train-ppa-service/4818 postgresql-14/14.2-1ubuntu1~ppa1
Waiting:
    Q-num pkg release arch ppa trigger
    1 postgresql-14 jammy ppc64el ci-train-ppa-service/4818 postgresql-14/14.2-1ubuntu1~ppa1

Assuming those pass, I think this looks good.

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

They all passed:
$ ./lp-test-ppa ppa:ci-train-ppa-service/4818 --release jammy --showpass
Tests for PPA 4818
---- ---- ---- ----
Release: jammy
Sources:
  SRC: postgresql-14 @ 14.2-1ubuntu1~ppa1 - Published
Triggers on published Sources:
         postgresql-14 @ amd64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @amd64 ♻️ Trigger all proposed @amd64 ♻️ 💍
         postgresql-14 @ s390x for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @s390x ♻️ Trigger all proposed @s390x ♻️ 💍
         postgresql-14 @ ppc64el for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @ppc64el ♻️ Trigger all proposed @ppc64el ♻️ 💍
         postgresql-14 @ arm64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @arm64 ♻️ Trigger all proposed @arm64 ♻️ 💍
         postgresql-14 @ armhf for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @armhf ♻️ Trigger all proposed @armhf ♻️ 💍
         postgresql-14 @ riscv64 for postgresql-14/14.2-1ubuntu1~ppa1 Trigger @riscv64 ♻️ Trigger all proposed @riscv64 ♻️ 💍
Results from https://autopkgtest.ubuntu.com/results/autopkgtest-jammy-ci-train-ppa-service-4818/?format=plain:
  postgresql-14 @ amd64:
    25.03.22 18:27:28 Log 🗒️ ✅ Triggers: ['postgresql-14/14.2-1ubuntu1~ppa1']
      run-testsuite PASS ✅
      installcheck PASS ✅
  postgresql-14 @ arm64:
    25.03.22 18:51:29 Log 🗒️ ✅ Triggers: ['postgresql-14/14.2-1ubuntu1~ppa1']
      run-testsuite PASS ✅
      installcheck PASS ✅
  postgresql-14 @ armhf:
    25.03.22 18:42:19 Log 🗒️ ✅ Triggers: ['postgresql-14/14.2-1ubuntu1~ppa1']
      run-testsuite PASS ✅
      installcheck PASS ✅
  postgresql-14 @ ppc64el:
    25.03.22 18:42:51 Log 🗒️ ✅ Triggers: ['postgresql-14/14.2-1ubuntu1~ppa1']
      run-testsuite PASS ✅
      installcheck PASS ✅
  postgresql-14 @ s390x:
    25.03.22 18:34:17 Log 🗒️ ✅ Triggers: ['postgresql-14/14.2-1ubuntu1~ppa1']
      run-testsuite PASS ✅
      installcheck PASS ✅
Running:
Waiting:

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Uploaded:

$ dput ubuntu ../postgresql-14_14.2-1ubuntu1_source.changes
D: Setting host argument.
Checking signature on .changes
gpg: ../postgresql-14_14.2-1ubuntu1_source.changes: Valid signature from AC983EB5BF6BCBA9
Checking signature on .dsc
gpg: ../postgresql-14_14.2-1ubuntu1.dsc: Valid signature from AC983EB5BF6BCBA9
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading postgresql-14_14.2-1ubuntu1.dsc: done.
  Uploading postgresql-14_14.2-1ubuntu1.debian.tar.xz: done.
  Uploading postgresql-14_14.2-1ubuntu1_source.buildinfo: done.
  Uploading postgresql-14_14.2-1ubuntu1_source.changes: done.
Successfully uploaded packages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index d6d439b..f8ba18f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+postgresql-14 (14.2-1ubuntu1) jammy; urgency=medium
7+
8+ * d/p/llvm14-support.patch: fix FTBFS with llvm-14 (LP: #1966319)
9+
10+ -- Andreas Hasenack <andreas@canonical.com> Fri, 25 Mar 2022 11:34:41 -0300
11+
12 postgresql-14 (14.2-1) unstable; urgency=medium
13
14 * New upstream release.
15diff --git a/debian/control b/debian/control
16index 0d6c863..a622aed 100644
17--- a/debian/control
18+++ b/debian/control
19@@ -1,7 +1,8 @@
20 Source: postgresql-14
21 Section: database
22 Priority: optional
23-Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
24+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
25+XSBC-Original-Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
26 Uploaders:
27 Martin Pitt <mpitt@debian.org>,
28 Peter Eisentraut <petere@debian.org>,
29diff --git a/debian/patches/llvm14-support.patch b/debian/patches/llvm14-support.patch
30new file mode 100644
31index 0000000..316dcb4
32--- /dev/null
33+++ b/debian/patches/llvm14-support.patch
34@@ -0,0 +1,155 @@
35+From d9f7ad54e552262ee0090e88d5abd3e04fcdeac8 Mon Sep 17 00:00:00 2001
36+From: Thomas Munro <tmunro@postgresql.org>
37+Date: Wed, 16 Mar 2022 11:35:00 +1300
38+Subject: [PATCH] Back-patch LLVM 14 API changes.
39+
40+Since LLVM 14 has stopped changing and is about to be released,
41+back-patch the following changes from the master branch:
42+
43+ e6a7600202105919bffd62b3dfd941f4a94e082b
44+ 807fee1a39de6bb8184082012e643951abb9ad1d
45+ a56e7b66010f330782243de9e25ac2a6596be0e1
46+
47+Back-patch to 11, where LLVM JIT support came in.
48+---
49+ src/backend/jit/llvm/Makefile | 6 +++++
50+ src/backend/jit/llvm/llvmjit_error.cpp | 35 +++++++++++++++++++++----
51+ src/backend/jit/llvm/llvmjit_inline.cpp | 12 ++++++++-
52+ 3 files changed, 47 insertions(+), 6 deletions(-)
53+
54+Origin: upstream, https://github.com/postgres/postgres/commit/d9f7ad54e552262ee0090e88d5abd3e04fcdeac8
55+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/postgresql-14/+bug/1966319
56+Last-Update: 2022-03-25
57+
58+diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
59+index 0268bd46d5c0..2da122a391e5 100644
60+--- a/src/backend/jit/llvm/Makefile
61++++ b/src/backend/jit/llvm/Makefile
62+@@ -22,6 +22,12 @@ endif
63+ PGFILEDESC = "llvmjit - JIT using LLVM"
64+ NAME = llvmjit
65+
66++# LLVM 14 produces deprecation warnings. We'll need to make some changes
67++# before the relevant functions are removed, but for now silence the warnings.
68++ifeq ($(GCC), yes)
69++LLVM_CFLAGS += -Wno-deprecated-declarations
70++endif
71++
72+ # All files in this directory use LLVM.
73+ CFLAGS += $(LLVM_CFLAGS)
74+ CXXFLAGS += $(LLVM_CXXFLAGS)
75+diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
76+index f4720732a39d..5ad92f30904d 100644
77+--- a/src/backend/jit/llvm/llvmjit_error.cpp
78++++ b/src/backend/jit/llvm/llvmjit_error.cpp
79+@@ -23,15 +23,22 @@ extern "C"
80+
81+ #include "jit/llvmjit.h"
82+
83++#include <new>
84+
85+ static int fatal_new_handler_depth = 0;
86+ static std::new_handler old_new_handler = NULL;
87+
88+ static void fatal_system_new_handler(void);
89+ #if LLVM_VERSION_MAJOR > 4
90++static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
91++#if LLVM_VERSION_MAJOR < 14
92+ static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
93+ #endif
94++#endif
95++static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
96++#if LLVM_VERSION_MAJOR < 14
97+ static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
98++#endif
99+
100+
101+ /*
102+@@ -129,23 +136,41 @@ fatal_system_new_handler(void)
103+ #if LLVM_VERSION_MAJOR > 4
104+ static void
105+ fatal_llvm_new_handler(void *user_data,
106+- const std::string& reason,
107++ const char *reason,
108+ bool gen_crash_diag)
109+ {
110+ ereport(FATAL,
111+ (errcode(ERRCODE_OUT_OF_MEMORY),
112+ errmsg("out of memory"),
113+- errdetail("While in LLVM: %s", reason.c_str())));
114++ errdetail("While in LLVM: %s", reason)));
115++}
116++#if LLVM_VERSION_MAJOR < 14
117++static void
118++fatal_llvm_new_handler(void *user_data,
119++ const std::string& reason,
120++ bool gen_crash_diag)
121++{
122++ fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
123+ }
124+ #endif
125++#endif
126+
127+ static void
128+ fatal_llvm_error_handler(void *user_data,
129+- const std::string& reason,
130++ const char *reason,
131+ bool gen_crash_diag)
132+ {
133+ ereport(FATAL,
134+ (errcode(ERRCODE_OUT_OF_MEMORY),
135+- errmsg("fatal llvm error: %s",
136+- reason.c_str())));
137++ errmsg("fatal llvm error: %s", reason)));
138+ }
139++
140++#if LLVM_VERSION_MAJOR < 14
141++static void
142++fatal_llvm_error_handler(void *user_data,
143++ const std::string& reason,
144++ bool gen_crash_diag)
145++{
146++ fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag);
147++}
148++#endif
149+diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
150+index 6f03595db5a4..9bb4b672a736 100644
151+--- a/src/backend/jit/llvm/llvmjit_inline.cpp
152++++ b/src/backend/jit/llvm/llvmjit_inline.cpp
153+@@ -594,7 +594,11 @@ function_inlinable(llvm::Function &F,
154+ if (F.materialize())
155+ elog(FATAL, "failed to materialize metadata");
156+
157+- if (F.getAttributes().hasFnAttribute(llvm::Attribute::NoInline))
158++#if LLVM_VERSION_MAJOR < 14
159++#define hasFnAttr hasFnAttribute
160++#endif
161++
162++ if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline))
163+ {
164+ ilog(DEBUG1, "ineligibile to import %s due to noinline",
165+ F.getName().data());
166+@@ -871,7 +875,9 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
167+ llvm::Function *AF;
168+ llvm::BasicBlock *BB;
169+ llvm::CallInst *fwdcall;
170++#if LLVM_VERSION_MAJOR < 14
171+ llvm::Attribute inlineAttribute;
172++#endif
173+
174+ AF = llvm::Function::Create(F->getFunctionType(),
175+ LinkageTypes::AvailableExternallyLinkage,
176+@@ -880,9 +886,13 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
177+
178+ Builder.SetInsertPoint(BB);
179+ fwdcall = Builder.CreateCall(F, &*AF->arg_begin());
180++#if LLVM_VERSION_MAJOR < 14
181+ inlineAttribute = llvm::Attribute::get(Context,
182+ llvm::Attribute::AlwaysInline);
183+ fwdcall->addAttribute(~0U, inlineAttribute);
184++#else
185++ fwdcall->addFnAttr(llvm::Attribute::AlwaysInline);
186++#endif
187+ Builder.CreateRet(fwdcall);
188+
189+ return AF;
190diff --git a/debian/patches/series b/debian/patches/series
191index 411958b..f6474db 100644
192--- a/debian/patches/series
193+++ b/debian/patches/series
194@@ -9,3 +9,4 @@ libpgport-pkglibdir
195 extension_destdir
196 autoconf2.69
197 focal-arm64-outline-atomics
198+llvm14-support.patch

Subscribers

People subscribed via source and target branches