diff -pruN 18.1-1/debian/changelog 18.1-1ubuntu1/debian/changelog
--- 18.1-1/debian/changelog	2025-11-11 12:05:55.000000000 +0000
+++ 18.1-1ubuntu1/debian/changelog	2025-11-21 06:50:08.000000000 +0000
@@ -1,3 +1,10 @@
+postgresql-18 (18.1-1ubuntu1) resolute; urgency=medium
+
+  * Backport upstream proposed patch for llvm-21 compilation fix
+    - this should fix arm64 FTBFS
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Fri, 21 Nov 2025 07:50:08 +0100
+
 postgresql-18 (18.1-1) unstable; urgency=medium
 
   * New upstream version 18.1.
diff -pruN 18.1-1/debian/patches/llvm-21-aarch64.patch 18.1-1ubuntu1/debian/patches/llvm-21-aarch64.patch
--- 18.1-1/debian/patches/llvm-21-aarch64.patch	1970-01-01 00:00:00.000000000 +0000
+++ 18.1-1ubuntu1/debian/patches/llvm-21-aarch64.patch	2025-11-21 06:49:24.000000000 +0000
@@ -0,0 +1,40 @@
+From da8c15ef4f8dbfe931fe2700d849f49078bfca97 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Holger=20Hoffst=C3=A4tte?= <holger@applied-asynchrony.com>
+Date: Fri, 12 Sep 2025 16:01:15 +0200
+Subject: [PATCH] jit: update aarch64-only use of SectionMemoryManager for
+ LLVM-21
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+LLVM-21 changed the invocation of RTDyldObjectLinkingLayer, breaking
+compilation with the backported SectionMemoryManager for aarch64.
+Introduce a version guard for the newly passed parameter.
+
+Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
+---
+ src/backend/jit/llvm/llvmjit_wrap.cpp | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/src/backend/jit/llvm/llvmjit_wrap.cpp b/src/backend/jit/llvm/llvmjit_wrap.cpp
+index da850d67ab6..d98e3d0d900 100644
+--- a/src/backend/jit/llvm/llvmjit_wrap.cpp
++++ b/src/backend/jit/llvm/llvmjit_wrap.cpp
+@@ -53,7 +53,14 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ObjectLayer, LLVMOrcObjectLayerRef
+ LLVMOrcObjectLayerRef
+ LLVMOrcCreateRTDyldObjectLinkingLayerWithSafeSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
+ {
++#if LLVM_VERSION_MAJOR >= 21
++	return wrap(new llvm::orc::RTDyldObjectLinkingLayer(
++		*unwrap(ES), [](const llvm::MemoryBuffer &) {
++			return std::make_unique<llvm::backport::SectionMemoryManager>(nullptr, true);
++		}));
++#else
+ 	return wrap(new llvm::orc::RTDyldObjectLinkingLayer(
+ 		*unwrap(ES), [] { return std::make_unique<llvm::backport::SectionMemoryManager>(nullptr, true); }));
++#endif
+ }
+ #endif
+-- 
+2.51.0
+
diff -pruN 18.1-1/debian/patches/series 18.1-1ubuntu1/debian/patches/series
--- 18.1-1/debian/patches/series	2025-11-11 12:05:55.000000000 +0000
+++ 18.1-1ubuntu1/debian/patches/series	2025-11-21 06:50:04.000000000 +0000
@@ -10,3 +10,4 @@ autoconf2.69
 pgstat-report-conflicts-immediately.patch
 libpq.pc-no-libcurl
 0001-Handle-EPERM-in-pg_numa_init.patch
+llvm-21-aarch64.patch
