FTBFS with llvm-14

Bug #1966319 reported by Andreas Hasenack
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
postgresql-14 (Ubuntu)
Fix Released
High
Andreas Hasenack

Bug Description

postgresql-14 is failing to build[1] in jammy.

I see llvm-14 deprecation warnings:
In file included from /<<PKGBUILDDIR>>/build/../src/backend/jit/llvm/llvmjit.c:38:
/<<PKGBUILDDIR>>/build/../src/include/jit/llvmjit_emit.h: In function ‘l_load_struct_gep’:
/<<PKGBUILDDIR>>/build/../src/include/jit/llvmjit_emit.h:112:9: warning: ‘LLVMBuildStructGEP’ is deprecated [-Wdeprecated-declarations]
  112 | LLVMValueRef v_ptr = LLVMBuildStructGEP(b, v, idx, "");
      | ^~~~~~~~~~~~
In file included from /usr/lib/llvm-14/include/llvm-c/Core.h:18,
                 from /<<PKGBUILDDIR>>/build/../src/backend/jit/llvm/llvmjit.c:19:
/usr/lib/llvm-14/include/llvm-c/Core.h:3909:18: note: declared here
 3909 | LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
      | ^~~~~~~~~~~~~~~~~~
/usr/lib/llvm-14/include/llvm-c/Deprecated.h:29:3: note: in definition of macro ‘LLVM_ATTRIBUTE_C_DEPRECATED’
   29 | decl __attribute__((deprecated))
      | ^~~~
In file included from /<<PKGBUILDDIR>>/build/../src/backend/jit/llvm/llvmjit.c:38:
/<<PKGBUILDDIR>>/build/../src/include/jit/llvmjit_emit.h:114:9: warning: ‘LLVMBuildLoad’ is deprecated [-Wdeprecated-declarations]
  114 | return LLVMBuildLoad(b, v_ptr, name);
      | ^~~~~~

And the previous build[2] was using llvm-13.

But there are also some errors:
   28 | static std::new_handler old_new_handler = NULL;
      | ^~~~~~~~~~~
/<<PKGBUILDDIR>>/build/../src/backend/jit/llvm/llvmjit_error.cpp:32:64: error: ‘string’ in namespace ‘std’ does not name a type
   32 | static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
      | ^~~~~~
/<<PKGBUILDDIR>>/build/../src/backend/jit/llvm/llvmjit_error.cpp:25:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
   24 | #include "jit/llvmjit.h"
  +++ |+#include <string>
   25 |

1. https://launchpadlibrarian.net/591985515/buildlog_ubuntu-jammy-amd64.postgresql-14_14.2-1_BUILDING.txt.gz
2. https://launchpadlibrarian.net/585392965/buildlog_ubuntu-jammy-amd64.postgresql-14_14.2-1_BUILDING.txt.gz

Related branches

Changed in postgresql-14 (Ubuntu):
importance: Undecided → High
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

That llvm v14 is rather recent - we were lucky that llvm-13 worked fine.
Officially the most recent postgresql-release just added llvm-12 support [1].

In jammy we have:
 llvm-13 | 1:13.0.1-2ubuntu2 | jammy/universe | amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
 llvm-14 | 1:14.0.0-1ubuntu1 | jammy-proposed/universe | amd64, arm64, armhf, i386, ppc64el, s390x

I can't see us transitioning completely to llvm-14 in time for jammy, so llvm-13 might stay as well? (ask Foundations please to be sure).
If it does stay, this might be as easy as putting a versioned build dep onto `llvm-dev` in d/control of postgresql-14.

On the other hand, maybe those are all just deprecation warnings and related follow on issues.
Having a test build with [2] might be worth a try.
Actually the REL_14_STABLE branch has a combined backport of this and other llvm-14 changes.
Those will be released with postgresql-14.3 some day, to fix it right now most likely the best shot would be [3]. And once 14.3 comes by we can drop our delta again.

[1]: https://www.postgresql.org/docs/14/release-14.html
[2]: https://github.com/postgres/postgres/commit/a56e7b66010f330782243de9e25ac2a6596be0e1
[3]: https://github.com/postgres/postgres/commit/d9f7ad54e552262ee0090e88d5abd3e04fcdeac8

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

I tried a rebuild with llvm-13 to see if it would work, and if we have a plan B just in case, and it worked.

This was the patch, for reference:
diff --git a/debian/control b/debian/control
index 0d6c8636f3..f7d18ae093 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Rules-Requires-Root: no
 Build-Depends:
  autoconf,
  bison,
- clang [!alpha !hppa !hurd-i386 !ia64 !kfreebsd-amd64 !kfreebsd-i386 !m68k !powerpc !riscv64 !s390x !sh4 !sparc64 !x32],
+ clang-13 [!alpha !hppa !hurd-i386 !ia64 !kfreebsd-amd64 !kfreebsd-i386 !m68k !powerpc !riscv64 !s390x !sh4 !sparc64 !x32],
  debhelper-compat (= 13),
  dh-exec (>= 0.13~),
  docbook-xml,
@@ -35,7 +35,7 @@ Build-Depends:
  libxml2-dev,
  libxml2-utils,
  libxslt1-dev,
- llvm-dev [!alpha !hppa !hurd-i386 !ia64 !kfreebsd-amd64 !kfreebsd-i386 !m68k !powerpc !riscv64 !s390x !sh4 !sparc64 !x32],
+ llvm-13-dev [!alpha !hppa !hurd-i386 !ia64 !kfreebsd-amd64 !kfreebsd-i386 !m68k !powerpc !riscv64 !s390x !sh4 !sparc64 !x32],
  mawk,
  perl (>= 5.8),
  pkg-config,

Now let's inspect those commits for llvm-14 and see how far I get

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

Foundations confirmed llvm-13 will stay. Ok, on to plan A.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package postgresql-14 - 14.2-1ubuntu1

---------------
postgresql-14 (14.2-1ubuntu1) jammy; urgency=medium

  * d/p/llvm14-support.patch: fix FTBFS with llvm-14 (LP: #1966319)

 -- Andreas Hasenack <email address hidden> Fri, 25 Mar 2022 11:34:41 -0300

Changed in postgresql-14 (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.