Subject: Re: Requiring LLVM 14+ in PostgreSQL 18

From: Thomas Munro <[email-masked]>
Date: Thu, 11 Apr 2024 14:16:39 +1200

On Wed, Apr 10, 2024 at 1:38 PM Thomas Munro <[email-masked]> wrote:
> Therefore, some time after the tree re-opens for hacking, we could rip
> out a bunch of support code for LLVM 10-13, and then rip out support
> for pre-opaque-pointer mode.  Please see attached.

... or of course closer to the end of the cycle if that's what people
prefer for some reason, I don't mind too much as long as it happens.

I added this to the commitfest app, and it promptly failed for cfbot.
That's expected: CI is still using Debian 11 "bullseye", which only
has LLVM 11.  It became what Debian calls "oldstable" last year, and
reaches the end of oldstable in a couple of months from now.  Debian
12 "bookworm" is the current stable release, and it has LLVM 14, so we
should probably go and update those CI images...

---

From: Thomas Munro <[email-masked]>
Date: Wed, 24 Apr 2024 11:43:12 +1200

Rebased over ca89db5f.

I looked into whether we could drop the "old pass manager" code
too[1].  Almost, but nope, even the C++ API lacks a way to set the
inline threshold before LLVM 16, so that would cause a regression.
Although we just hard-code the threshold to 512 with a comment that
sounds like it's pretty arbitrary, a change to the default (225?)
would be unjustifiable just for code cleanup.  Oh well.

[1] https://github.com/macdice/postgres/commit/0d40abdf1feb75210c3a3d2a35e3d6146185974c

---

From: Peter Eisentraut <[email-masked]>
Date: Sun, 12 May 2024 16:32:59 +0200

> Rebased over ca89db5f.

These patches look fine to me.  The new cut-off makes sense, and it does 
save quite a bit of code.  We do need to get the Cirrus CI Debian images 
updated first, as you had already written.

As part of this patch, you also sneak in support for LLVM 18 
(llvm-config-18, clang-18 in configure).  Should this be a separate patch?

And as I'm looking up how this was previously handled, I notice that 
this list of clang-NN versions was last updated equally sneakily as part 
of your patch to trim off LLVM <10 (820b5af73dc).  I wonder if the 
original intention of that configure code was that maintaining the 
versioned list above clang-7/llvm-config-7 was not needed, because the 
unversioning programs could be used, or maybe because pkg-config could 
be used.  It would be nice if we could get rid of having to update that.

---

From: Thomas Munro <[email-masked]>
Date: Wed, 15 May 2024 16:21:25 +1200

> updated first, as you had already written.

Thanks for looking!

> (llvm-config-18, clang-18 in configure).  Should this be a separate patch?

Yeah, right, I didn't really think too hard about why we have that,
and now that you question it...

> be used.  It would be nice if we could get rid of having to update that.

I probably misunderstood why we were doing that, perhaps something to
do with the way some distro (Debian?) was doing things with older
versions, and yeah I see that we went a long time after 7 without
touching it and nobody cared.  Yeah, it would be nice to get rid of
it.  Here's a patch.  Meson didn't have that.
From 025f8b0106821b5b6f2ab7992da388404e3e406c Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Wed, 15 May 2024 15:51:28 +1200
Subject: [PATCH v3 1/3] jit: Remove configure probes for {lvm-config,clang}-N.

Previously we searched for llvm-config-N and clang-N as well as the
unversioned names, and maintained a list of expected values of N.  There
doesn't seem to be any reason to think that the default llvm-config and
clang won't be good enough, and if they aren't, they can be overridden
with LLVM_CONFIG and CLANG, so let's stop maintaining that list.

The Meson build system didn't do that, so this brings them into sync.

Suggested-by: Peter Eisentraut <[email-masked]>
Discussion: https://postgr.es/m/CA%2BhUKG%2BSOP-aR%3DYF_n0dtXGWeCy6x%2BCn-RMWURU5ySQdmeKW1Q%40mail.gmail.com
---
 config/llvm.m4 | 4 ++--
 configure      | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/config/llvm.m4 b/config/llvm.m4
index 44769d819a0..c6cf8858f64 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -13,7 +13,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
   AC_REQUIRE([AC_PROG_AWK])
 
   AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config command])
-  PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10)
+  PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config)
 
   # no point continuing if llvm wasn't found
   if test -z "$LLVM_CONFIG"; then
@@ -32,7 +32,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
 
   # need clang to create some bitcode files
   AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode])
-  PGAC_PATH_PROGS(CLANG, clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10)
+  PGAC_PATH_PROGS(CLANG, clang)
   if test -z "$CLANG"; then
     AC_MSG_ERROR([clang not found, but required when compiling --with-llvm, specify with CLANG=])
   fi
diff --git a/configure b/configure
index 89644f2249e..8e7704d54bd 100755
--- a/configure
+++ b/configure
@@ -5065,7 +5065,7 @@ if test "$with_llvm" = yes; then :

   if test -z "$LLVM_CONFIG"; then
-  for ac_prog in llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10
+  for ac_prog in llvm-config
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -5138,7 +5138,7 @@ $as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}
   # need clang to create some bitcode files
 
   if test -z "$CLANG"; then
-  for ac_prog in clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10
+  for ac_prog in clang
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-- 
2.39.2

From ef1c38dbb1ec8a6a762c88ee50c55a87693d44f6 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Thu, 19 Oct 2023 04:45:46 +1300
Subject: [PATCH v3 2/3] jit: Require at least LLVM 14, if enabled.

Remove support for LLVM versions 10-13.  The default on all non-EOL'd
OSes represented in our build farm will be at least LLVM 14 when
PostgreSQL 18 ships.

Reviewed-by: Peter Eisentraut <[email-masked]>
Discussion: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com
---
 config/llvm.m4                          |   4 +-
 configure                               |   4 +-
 doc/src/sgml/installation.sgml          |   4 +-
 meson.build                             |   2 +-
 src/backend/jit/llvm/llvmjit.c          | 101 ------------------------
 src/backend/jit/llvm/llvmjit_error.cpp  |  25 ------
 src/backend/jit/llvm/llvmjit_inline.cpp |  13 ---
 src/backend/jit/llvm/llvmjit_wrap.cpp   |   4 -
 8 files changed, 7 insertions(+), 150 deletions(-)

diff --git a/config/llvm.m4 b/config/llvm.m4
index c6cf8858f64..fa4bedd9370 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -25,8 +25,8 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
     AC_MSG_ERROR([$LLVM_CONFIG does not work])
   fi
   # and whether the version is supported
-  if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 10) exit 1; else exit 0;}';then
-    AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required])
+  if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 14) exit 1; else exit 0;}';then
+    AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 14 is required])
   fi
   AC_MSG_NOTICE([using llvm $pgac_llvm_version])
 
diff --git a/configure b/configure
index 8e7704d54bd..4b72a0d9f6a 100755
--- a/configure
+++ b/configure
@@ -5129,8 +5129,8 @@ fi
     as_fn_error $? "$LLVM_CONFIG does not work" "$LINENO" 5
   fi
   # and whether the version is supported
-  if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 10) exit 1; else exit 0;}';then
-    as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required" "$LINENO" 5
+  if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 14) exit 1; else exit 0;}';then
+    as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 14 is required" "$LINENO" 5
   fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: using llvm $pgac_llvm_version" >&5
 $as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1b32d5ca62c..91dadc10fbb 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -936,7 +936,7 @@ build-postgresql:
          <acronym>JIT</acronym> compilation (see <xref linkend="jit"/>).  This
          requires the <productname>LLVM</productname> library to be installed.
          The minimum required version of <productname>LLVM</productname> is
-         currently 10.
+         currently 14.
         </para>
         <para>
          <command>llvm-config</command><indexterm><primary>llvm-config</primary></indexterm>
@@ -2424,7 +2424,7 @@ ninja install
         <acronym>JIT</acronym> compilation (see <xref linkend="jit"/>).
         This requires the <productname>LLVM</productname> library to be
         installed.  The minimum required version of
-        <productname>LLVM</productname> is currently 10.  Disabled by
+        <productname>LLVM</productname> is currently 14.  Disabled by
         default.
        </para>
 
diff --git a/meson.build b/meson.build
index 1c0579d5a6b..1b845203780 100644
--- a/meson.build
+++ b/meson.build
@@ -748,7 +748,7 @@ endif
 llvmopt = get_option('llvm')
 llvm = not_found_dep
 if add_languages('cpp', required: llvmopt, native: false)
-  llvm = dependency('llvm', version: '>=10', method: 'config-tool', required: llvmopt)
+  llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt)
 
   if llvm.found()
 
diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 1d439f24554..8f9c77eedc1 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -21,13 +21,9 @@
 #if LLVM_VERSION_MAJOR > 16
 #include <llvm-c/Transforms/PassBuilder.h>
 #endif
-#if LLVM_VERSION_MAJOR > 11
 #include <llvm-c/Orc.h>
 #include <llvm-c/OrcEE.h>
 #include <llvm-c/LLJIT.h>
-#else
-#include <llvm-c/OrcBindings.h>
-#endif
 #include <llvm-c/Support.h>
 #include <llvm-c/Target.h>
 #if LLVM_VERSION_MAJOR < 17
@@ -50,13 +46,8 @@
 /* Handle of a module emitted via ORC JIT */
 typedef struct LLVMJitHandle
 {
-#if LLVM_VERSION_MAJOR > 11
 	LLVMOrcLLJITRef lljit;
 	LLVMOrcResourceTrackerRef resource_tracker;
-#else
-	LLVMOrcJITStackRef stack;
-	LLVMOrcModuleHandle orc_handle;
-#endif
 } LLVMJitHandle;

@@ -103,14 +94,9 @@ static LLVMContextRef llvm_context;

 static LLVMTargetRef llvm_targetref;
-#if LLVM_VERSION_MAJOR > 11
 static LLVMOrcThreadSafeContextRef llvm_ts_context;
 static LLVMOrcLLJITRef llvm_opt0_orc;
 static LLVMOrcLLJITRef llvm_opt3_orc;
-#else							/* LLVM_VERSION_MAJOR > 11 */
-static LLVMOrcJITStackRef llvm_opt0_orc;
-static LLVMOrcJITStackRef llvm_opt3_orc;
-#endif							/* LLVM_VERSION_MAJOR > 11 */

 static void llvm_release_context(JitContext *context);
@@ -124,10 +110,8 @@ static void llvm_set_target(void);
 static void llvm_recreate_llvm_context(void);
 static uint64_t llvm_resolve_symbol(const char *name, void *ctx);
 
-#if LLVM_VERSION_MAJOR > 11
 static LLVMOrcLLJITRef llvm_create_jit_instance(LLVMTargetMachineRef tm);
 static char *llvm_error_message(LLVMErrorRef error);
-#endif							/* LLVM_VERSION_MAJOR > 11 */
 
 /* ResourceOwner callbacks to hold JitContexts  */
 static void ResOwnerReleaseJitContext(Datum res);
@@ -292,7 +276,6 @@ llvm_release_context(JitContext *context)
 	{
 		LLVMJitHandle *jit_handle = (LLVMJitHandle *) lfirst(lc);
 
-#if LLVM_VERSION_MAJOR > 11
 		{
 			LLVMOrcExecutionSessionRef ee;
 			LLVMOrcSymbolStringPoolRef sp;
@@ -310,11 +293,6 @@ llvm_release_context(JitContext *context)
 			sp = LLVMOrcExecutionSessionGetSymbolStringPool(ee);
 			LLVMOrcSymbolStringPoolClearDeadEntries(sp);
 		}
-#else							/* LLVM_VERSION_MAJOR > 11 */
-		{
-			LLVMOrcRemoveModule(jit_handle->stack, jit_handle->orc_handle);
-		}
-#endif							/* LLVM_VERSION_MAJOR > 11 */
 
 		pfree(jit_handle);
 	}
@@ -397,7 +375,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
 	 * to mangle here.
 	 */
 
-#if LLVM_VERSION_MAJOR > 11
 	foreach(lc, context->handles)
 	{
 		LLVMJitHandle *handle = (LLVMJitHandle *) lfirst(lc);
@@ -427,19 +404,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
 		if (addr)
 			return (void *) (uintptr_t) addr;
 	}
-#else
-	foreach(lc, context->handles)
-	{
-		LLVMOrcTargetAddress addr;
-		LLVMJitHandle *handle = (LLVMJitHandle *) lfirst(lc);
-
-		addr = 0;
-		if (LLVMOrcGetSymbolAddressIn(handle->stack, &addr, handle->orc_handle, funcname))
-			elog(ERROR, "failed to look up symbol \"%s\"", funcname);
-		if (addr)
-			return (void *) (uintptr_t) addr;
-	}
-#endif
 
 	elog(ERROR, "failed to JIT: %s", funcname);
 
@@ -735,11 +699,7 @@ llvm_compile_module(LLVMJitContext *context)
 	MemoryContext oldcontext;
 	instr_time	starttime;
 	instr_time	endtime;
-#if LLVM_VERSION_MAJOR > 11
 	LLVMOrcLLJITRef compile_orc;
-#else
-	LLVMOrcJITStackRef compile_orc;
-#endif
 
 	if (context->base.flags & PGJIT_OPT3)
 		compile_orc = llvm_opt3_orc;
@@ -796,7 +756,6 @@ llvm_compile_module(LLVMJitContext *context)
 	 * faster instruction selection mechanism is used.
 	 */
 	INSTR_TIME_SET_CURRENT(starttime);
-#if LLVM_VERSION_MAJOR > 11
 	{
 		LLVMOrcThreadSafeModuleRef ts_module;
 		LLVMErrorRef error;
@@ -824,16 +783,6 @@ llvm_compile_module(LLVMJitContext *context)
 
 		/* LLVMOrcLLJITAddLLVMIRModuleWithRT takes ownership of the module */
 	}
-#else
-	{
-		handle->stack = compile_orc;
-		if (LLVMOrcAddEagerlyCompiledIR(compile_orc, &handle->orc_handle, context->module,
-										llvm_resolve_symbol, NULL))
-			elog(ERROR, "failed to JIT module");
-
-		/* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
-	}
-#endif
 
 	INSTR_TIME_SET_CURRENT(endtime);
 	INSTR_TIME_ACCUM_DIFF(context->base.instr.emission_counter,
@@ -945,7 +894,6 @@ llvm_session_initialize(void)
 	/* force symbols in main binary to be loaded */
 	LLVMLoadLibraryPermanently(NULL);
 
-#if LLVM_VERSION_MAJOR > 11
 	{
 		llvm_ts_context = LLVMOrcCreateNewThreadSafeContext();
 
@@ -955,31 +903,6 @@ llvm_session_initialize(void)
 		llvm_opt3_orc = llvm_create_jit_instance(opt3_tm);
 		opt3_tm = 0;
 	}
-#else							/* LLVM_VERSION_MAJOR > 11 */
-	{
-		llvm_opt0_orc = LLVMOrcCreateInstance(opt0_tm);
-		llvm_opt3_orc = LLVMOrcCreateInstance(opt3_tm);
-
-#if defined(HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER) && HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER
-		if (jit_debugging_support)
-		{
-			LLVMJITEventListenerRef l = LLVMCreateGDBRegistrationListener();
-
-			LLVMOrcRegisterJITEventListener(llvm_opt0_orc, l);
-			LLVMOrcRegisterJITEventListener(llvm_opt3_orc, l);
-		}
-#endif
-#if defined(HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER) && HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER
-		if (jit_profiling_support)
-		{
-			LLVMJITEventListenerRef l = LLVMCreatePerfJITEventListener();
-
-			LLVMOrcRegisterJITEventListener(llvm_opt0_orc, l);
-			LLVMOrcRegisterJITEventListener(llvm_opt3_orc, l);
-		}
-#endif
-	}
-#endif							/* LLVM_VERSION_MAJOR > 11 */
 
 	on_proc_exit(llvm_shutdown, 0);
 
@@ -1009,7 +932,6 @@ llvm_shutdown(int code, Datum arg)
 		elog(PANIC, "LLVMJitContext in use count not 0 at exit (is %zu)",
 			 llvm_jit_context_in_use_count);
 
-#if LLVM_VERSION_MAJOR > 11
 	{
 		if (llvm_opt3_orc)
 		{
@@ -1027,23 +949,6 @@ llvm_shutdown(int code, Datum arg)
 			llvm_ts_context = NULL;
 		}
 	}
-#else							/* LLVM_VERSION_MAJOR > 11 */
-	{
-		/* unregister profiling support, needs to be flushed to be useful */
-
-		if (llvm_opt3_orc)
-		{
-			LLVMOrcDisposeInstance(llvm_opt3_orc);
-			llvm_opt3_orc = NULL;
-		}
-
-		if (llvm_opt0_orc)
-		{
-			LLVMOrcDisposeInstance(llvm_opt0_orc);
-			llvm_opt0_orc = NULL;
-		}
-	}
-#endif							/* LLVM_VERSION_MAJOR > 11 */
 }
 
 /* helper for llvm_create_types, returning a function's return type */
@@ -1213,8 +1118,6 @@ llvm_resolve_symbol(const char *symname, void *ctx)
 	return (uint64_t) addr;
 }
 
-#if LLVM_VERSION_MAJOR > 11
-
 static LLVMErrorRef
 llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
 					 LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind,
@@ -1233,9 +1136,7 @@ llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
 	{
 		const char *name = LLVMOrcSymbolStringPoolEntryStr(LookupSet[i].Name);
 
-#if LLVM_VERSION_MAJOR > 12
 		LLVMOrcRetainSymbolStringPoolEntry(LookupSet[i].Name);
-#endif
 		symbols[i].Name = LookupSet[i].Name;
 		symbols[i].Sym.Address = llvm_resolve_symbol(name, NULL);
 		symbols[i].Sym.Flags.GenericFlags = LLVMJITSymbolGenericFlagsExported;
@@ -1364,8 +1265,6 @@ llvm_error_message(LLVMErrorRef error)
 	return msg;
 }
 
-#endif							/* LLVM_VERSION_MAJOR > 11 */
-
 /*
  * ResourceOwner callbacks
  */
diff --git a/src/backend/jit/llvm/llvmjit_error.cpp b/src/backend/jit/llvm/llvmjit_error.cpp
index ebe2f1baa10..351354c30bc 100644
--- a/src/backend/jit/llvm/llvmjit_error.cpp
+++ b/src/backend/jit/llvm/llvmjit_error.cpp
@@ -30,13 +30,7 @@ static std::new_handler old_new_handler = NULL;
 
 static void fatal_system_new_handler(void);
 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
 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

 /*
@@ -135,15 +129,6 @@ fatal_llvm_new_handler(void *user_data,
 			 errmsg("out of memory"),
 			 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
 
 static void
 fatal_llvm_error_handler(void *user_data,
@@ -154,13 +139,3 @@ fatal_llvm_error_handler(void *user_data,
 			(errcode(ERRCODE_OUT_OF_MEMORY),
 			 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 2007eb523c9..23a8053311d 100644
--- a/src/backend/jit/llvm/llvmjit_inline.cpp
+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
@@ -594,10 +594,6 @@ function_inlinable(llvm::Function &F,
 	if (F.materialize())
 		elog(FATAL, "failed to materialize metadata");
 
-#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",
@@ -858,9 +854,6 @@ 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,
@@ -869,13 +862,7 @@ 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;
diff --git a/src/backend/jit/llvm/llvmjit_wrap.cpp b/src/backend/jit/llvm/llvmjit_wrap.cpp
index 641c8841ca3..7f7623dac64 100644
--- a/src/backend/jit/llvm/llvmjit_wrap.cpp
+++ b/src/backend/jit/llvm/llvmjit_wrap.cpp
@@ -17,10 +17,6 @@ extern "C"
 }
 
 #include <llvm-c/Core.h>
-
-/* Avoid macro clash with LLVM's C++ headers */
-#undef Min
-
 #include <llvm/IR/Function.h>
 
 #include "jit/llvmjit.h"
-- 
2.39.2

From 6607ad80e858257a589c7bf25464e027a4b310af Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Fri, 20 Oct 2023 15:13:26 +1300
Subject: [PATCH v3 3/3] jit: Use opaque pointers in all supported LLVM
 versions.

LLVM's opaque pointer change began in LLVM 14, but remained optional
until LLVM 16.  When commit 37d5babb added opaque pointer support, we
didn't turn it on for LLVM 14 and 15 yet because we didn't want to risk
weird bitcode incompatibility problems in released branches of
PostgreSQL.  (That might have been overly cautious, I don't know.)

Now that PostgreSQL 18 has dropped support for LLVM versions < 14, and
since it hasn't been released yet and no extensions or bitcode have been
built against it in the wild yet, we can be more aggressive.  We can rip
out the support code and build system clutter that made opaque pointer
use optional.

Reviewed-by: Peter Eisentraut <[email-masked]>
Discussions: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com
---
 configure                        | 89 --------------------------------
 configure.ac                     |  3 --
 src/backend/jit/llvm/llvmjit.c   | 13 -----
 src/backend/jit/llvm/meson.build |  3 --
 src/include/jit/llvmjit_emit.h   | 16 ------
 5 files changed, 124 deletions(-)

diff --git a/configure b/configure
index 4b72a0d9f6a..abad7553f8b 100755
--- a/configure
+++ b/configure
@@ -7290,95 +7290,6 @@ 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 c7322e292cc..86961b90eff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -634,9 +634,6 @@ 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 8f9c77eedc1..9960a0239c8 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -835,19 +835,6 @@ llvm_session_initialize(void)
 		llvm_llvm_context_reuse_count = 0;
 	}
 
-	/*
-	 * When targeting LLVM 15, turn off opaque pointers 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.
-	 *
-	 * For 16 and above, opaque pointers must be used, and we have special
-	 * code for that.
-	 */
-#if LLVM_VERSION_MAJOR == 15
-	LLVMContextSetOpaquePointers(LLVMGetGlobalContext(), false);
-#endif
-
 	/*
 	 * Synchronize types early, as that also includes inferring the target
 	 * triple.
diff --git a/src/backend/jit/llvm/meson.build b/src/backend/jit/llvm/meson.build
index 41c759f73c5..88b4a212bd1 100644
--- a/src/backend/jit/llvm/meson.build
+++ b/src/backend/jit/llvm/meson.build
@@ -60,9 +60,6 @@ endif
 
 # XXX: Need to determine proper version of the function cflags for clang
 bitcode_cflags = ['-fno-strict-aliasing', '-fwrapv']
-if llvm.version().version_compare('=15.0')
-  bitcode_cflags += ['-Xclang', '-no-opaque-pointers']
-endif
 bitcode_cflags += cppflags
 
 # XXX: Worth improving on the logic to find directories here
diff --git a/src/include/jit/llvmjit_emit.h b/src/include/jit/llvmjit_emit.h
index 4f35f3dca13..0a04c85d9b9 100644
--- a/src/include/jit/llvmjit_emit.h
+++ b/src/include/jit/llvmjit_emit.h
@@ -107,41 +107,25 @@ l_pbool_const(bool i)
 static inline LLVMValueRef
 l_struct_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, int32 idx, const char *name)
 {
-#if LLVM_VERSION_MAJOR < 16
-	return LLVMBuildStructGEP(b, v, idx, "");
-#else
 	return LLVMBuildStructGEP2(b, t, v, idx, "");
-#endif
 }
 
 static inline LLVMValueRef
 l_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, LLVMValueRef *indices, int32 nindices, const char *name)
 {
-#if LLVM_VERSION_MAJOR < 16
-	return LLVMBuildGEP(b, v, indices, nindices, name);
-#else
 	return LLVMBuildGEP2(b, t, v, indices, nindices, name);
-#endif
 }
 
 static inline LLVMValueRef
 l_load(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, const char *name)
 {
-#if LLVM_VERSION_MAJOR < 16
-	return LLVMBuildLoad(b, v, name);
-#else
 	return LLVMBuildLoad2(b, t, v, name);
-#endif
 }
 
 static inline LLVMValueRef
 l_call(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef fn, LLVMValueRef *args, int32 nargs, const char *name)
 {
-#if LLVM_VERSION_MAJOR < 16
-	return LLVMBuildCall(b, fn, args, nargs, name);
-#else
 	return LLVMBuildCall2(b, t, fn, args, nargs, name);
-#endif
 }
 
 /*
-- 
2.39.2

---

From: Peter Eisentraut <[email-masked]>
Date: Wed, 15 May 2024 07:20:09 +0200

> it.  Here's a patch.  Meson didn't have that.

Yes, let's get that v3-0001 patch into PG17.

---

From: Thomas Munro <[email-masked]>
Date: Thu, 16 May 2024 14:33:37 +1200

> Yes, let's get that v3-0001 patch into PG17.

Done.

Bilal recently created the CI images for Debian Bookworm[1].  You can
try them with s/bullseye/bookworm/ in .cirrus.tasks.yml, but it looks
like he is still wrestling with a perl installation problem[2] in the
32 bit build, so here is a temporary patch to do that and also delete
the 32 bit tests for now.  This way cfbot should succeed with the
remaining patches.  Parked here for v18.

[1] https://github.com/anarazel/pg-vm-images/commit/685ca7ccb7b3adecb11d948ac677d54cd9599e6c
[2] https://cirrus-ci.com/task/5459439048720384
From c0a05c2929e03558c730b148bdeb5d301dbc4312 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Thu, 16 May 2024 14:10:09 +1200
Subject: [PATCH v4 1/3] XXX CI kludge: bullseye->bookworm

Temporarily removed 32 bit tests, as the CI image is not fully baked
yet.
---
 .cirrus.tasks.yml | 37 +++++--------------------------------
 1 file changed, 5 insertions(+), 32 deletions(-)

diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index a2388cd5036..5ff6b6a0556 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -65,7 +65,7 @@ task:
     CPUS: 4
     BUILD_JOBS: 8
     TEST_JOBS: 8
-    IMAGE_FAMILY: pg-ci-bullseye
+    IMAGE_FAMILY: pg-ci-bookworm
     CCACHE_DIR: ${CIRRUS_WORKING_DIR}/ccache_dir
     # no options enabled, should be small
     CCACHE_MAXSIZE: "150M"
@@ -243,7 +243,7 @@ task:
     CPUS: 4
     BUILD_JOBS: 4
     TEST_JOBS: 8 # experimentally derived to be a decent choice
-    IMAGE_FAMILY: pg-ci-bullseye
+    IMAGE_FAMILY: pg-ci-bookworm
 
     CCACHE_DIR: /tmp/ccache_dir
     DEBUGINFOD_URLS: "https://debuginfod.debian.net"
@@ -314,7 +314,7 @@ task:
     #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
 
   matrix:
-    - name: Linux - Debian Bullseye - Autoconf
+    - name: Linux - Debian Bookworm - Autoconf
 
       env:
         SANITIZER_FLAGS: -fsanitize=address
@@ -348,7 +348,7 @@ task:
       on_failure:
         <<: *on_failure_ac
 
-    - name: Linux - Debian Bullseye - Meson
+    - name: Linux - Debian Bookworm - Meson
 
       env:
         CCACHE_MAXSIZE: "400M" # tests two different builds
@@ -364,24 +364,7 @@ task:
             build
         EOF
 
-      # Also build & test in a 32bit build - it's gotten rare to test that
-      # locally.
-      configure_32_script: |
-        su postgres <<-EOF
-          export CC='ccache gcc -m32'
-          meson setup \
-            --buildtype=debug \
-            -Dcassert=true -Dinjection_points=true \
-            ${LINUX_MESON_FEATURES} \
-            -Dllvm=disabled \
-            --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
-            -DPERL=perl5.32-i386-linux-gnu \
-            -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
-            build-32
-        EOF
-
       build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS}'
-      build_32_script: su postgres -c 'ninja -C build-32 -j${BUILD_JOBS}'
 
       upload_caches: ccache
 
@@ -393,16 +376,6 @@ task:
         # so that we don't upload 64bit logs if 32bit fails
         rm -rf build/
 
-      # There's currently no coverage of icu with LANG=C in the buildfarm. We
-      # can easily provide some here by running one of the sets of tests that
-      # way. Newer versions of python insist on changing the LC_CTYPE away
-      # from C, prevent that with PYTHONCOERCECLOCALE.
-      test_world_32_script: |
-        su postgres <<-EOF
-          ulimit -c unlimited
-          PYTHONCOERCECLOCALE=0 LANG=C meson test $MTEST_ARGS -C build-32 --num-processes ${TEST_JOBS}
-        EOF
-
       on_failure:
         <<: *on_failure_meson
 
@@ -652,7 +625,7 @@ task:
   env:
     CPUS: 4
     BUILD_JOBS: 4
-    IMAGE_FAMILY: pg-ci-bullseye
+    IMAGE_FAMILY: pg-ci-bookworm
 
     # Use larger ccache cache, as this task compiles with multiple compilers /
     # flag combinations
-- 
2.39.2

From bcdb3453b50cd37077ad71f012d7f92c9842495f Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Thu, 19 Oct 2023 04:45:46 +1300
Subject: [PATCH v4 2/3] jit: Require at least LLVM 14, if enabled.

 

   if llvm.found()

 

 
 		pfree(jit_handle);
 	}

 

 

 

 

 

 /*
 
 static void

 
 
 	return AF;
 
 #include <llvm-c/Core.h>
-
 
 #include "jit/llvmjit.h"
-- 
2.39.2

From c4d4fa7a3e016c5a5b2e59eb23d56ca53eadfa41 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Fri, 20 Oct 2023 15:13:26 +1300
Subject: [PATCH v4 3/3] jit: Use opaque pointers in all supported LLVM
 versions.

 
 
-	/*

 

 
 /*
-- 
2.39.2

---

From: Nazir Bilal Yavuz <[email-masked]>
Date: Thu, 16 May 2024 18:17:08 +0300

Hi,

> remaining patches.  Parked here for v18.

Actually, 32 bit builds are working but the Perl version needs to be
updated to 'perl5.36-i386-linux-gnu' in .cirrus.tasks.yml. I changed
0001 with the working version of 32 bit builds [1] and the rest is the
same. All tests pass now [2].

[1] postgr.es/m/CAN55FZ0fY5EFHXLKCO_=[email-masked]
[2] https://cirrus-ci.com/task/4969910856581120

-- 
Regards,
Nazir Bilal Yavuz
Microsoft
From 976d2c7ad0e470b24875ee27171359f54078a761 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <[email-masked]>
Date: Mon, 13 May 2024 10:56:28 +0300
Subject: [PATCH v5 1/3] Upgrade Debian CI images to Bookworm

New Debian version, namely Bookworm, is released. Use these new images
in CI tasks.

Perl version is upgraded in the Bookworm images, so update Perl version
at 'Linux - Debian Bookworm - Meson' task as well.

Upgrading Debian CI images to Bookworm PR: https://github.com/anarazel/pg-vm-images/pull/91
---
 .cirrus.tasks.yml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

index a2388cd5036..47a60aa7c6f 100644

   matrix:
 
       env:

       env:
         CCACHE_MAXSIZE: "400M" # tests two different builds
@@ -375,7 +375,7 @@ task:
             ${LINUX_MESON_FEATURES} \
             -Dllvm=disabled \
             --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
-            -DPERL=perl5.32-i386-linux-gnu \
+            -DPERL=perl5.36-i386-linux-gnu \
             -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
             build-32
         EOF
@@ -652,7 +652,7 @@ task:
   env:
     CPUS: 4
     BUILD_JOBS: 4
-    IMAGE_FAMILY: pg-ci-bullseye
+    IMAGE_FAMILY: pg-ci-bookworm
 
2.43.0

From a18120ace64bcde41c2ed23a050eb86f9b8772e0 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Thu, 19 Oct 2023 04:45:46 +1300
Subject: [PATCH v5 2/3] jit: Require at least LLVM 14, if enabled.

 

 
 		pfree(jit_handle);
 	}

 

 

 

 

 

 /*
 
 static void

 
 
 	return AF;
 
 #include <llvm-c/Core.h>
-
 
 #include "jit/llvmjit.h"

 
   if llvm.found()
 
-- 
2.43.0

From e570133b50361777a369fd385e186385d03b79fa Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email-masked]>
Date: Fri, 20 Oct 2023 15:13:26 +1300
Subject: [PATCH v5 3/3] jit: Use opaque pointers in all supported LLVM
 versions.

 

 
 /*
 
-	/*

 
2.43.0

---

From: Thomas Munro <[email-masked]>
Date: Fri, 17 May 2024 10:54:45 +1200

> same. All tests pass now [2].

Ahh, right, thanks!  I will look at committing your CI/fixup patches.

---

From: Ole Peder Brandtzæg <[email-masked]>
Date: Sun, 19 May 2024 00:46:01 +0200

> Yes, let's get that v3-0001 patch into PG17.

Upon seeing this get committed in 4dd29b6833, I noticed that the docs
still advertise the llvm-config-$version search dance. That's still
correct for Meson-based builds since we use their config-tool machinery,
but no longer holds for configure-based builds. The attached patch
updates the docs accordingly.

-- 
Ole Peder Brandtzæg
In any case, these nights just ain't getting any easier
And who could judge us
For seeking comfort in the hazy counterfeit land of memory
>From 61dfbf5a252b53697cce17cd4885ecddb7665814 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ole=20Peder=20Brandtz=C3=A6g?= <[email-masked]>
Date: Sun, 19 May 2024 00:29:09 +0200
Subject: [PATCH] doc: remove llvm-config search from configure documentation

As of 4dd29b6833, we no longer attempt to locate any other llvm-config
variant than plain llvm-config in configure-based builds; update the
documentation accordingly. (For Meson-based builds, we still use Meson's
LLVMDependencyConfigTool [0], which runs through a set of possible
suffixes [1], so no need to update the documentation there.)

[0]: https://github.com/mesonbuild/meson/blob/7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/dependencies/dev.py#L184
[1]: https://github.com/mesonbuild/meson/blob/7d28ff29396f9d7043204de8ddc52226b9903811/mesonbuild/environment.py#L183
---
 doc/src/sgml/installation.sgml | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1b32d5ca62..19abec2c34 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -941,12 +941,9 @@ build-postgresql:
         <para>
          <command>llvm-config</command><indexterm><primary>llvm-config</primary></indexterm>
          will be used to find the required compilation options.
-         <command>llvm-config</command>, and then
-         <command>llvm-config-$major-$minor</command> for all supported
-         versions, will be searched for in your <envar>PATH</envar>.  If
-         that would not yield the desired program,
-         use <envar>LLVM_CONFIG</envar> to specify a path to the
-         correct <command>llvm-config</command>. For example
+         <command>llvm-config</command> will be searched for in your <envar>PATH</envar>.
+         If that would not yield the desired program, use <envar>LLVM_CONFIG</envar> to
+         specify a path to the correct <command>llvm-config</command>. For example
 <programlisting>
 ./configure ... --with-llvm LLVM_CONFIG='/path/to/llvm/bin/llvm-config'
 </programlisting>
-- 
2.43.0

---

From: Thomas Munro <[email-masked]>
Date: Sun, 19 May 2024 11:05:49 +1200

> updates the docs accordingly.

Oops, right I didn't know we had that documented.  Thanks.  Will hold
off doing anything until the thaw.

Hmm, I also didn't know that Meson had its own list like our just-removed one:

https://github.com/mesonbuild/meson/blob/master/mesonbuild/environment.py#L183

Unsurprisingly, it suffers from maintenance lag, priority issues etc
(new major versions pop out every 6 months):

https://github.com/mesonbuild/meson/issues/10483

---

From: Ole Peder Brandtzæg <[email-masked]>
Date: Sun, 19 May 2024 01:16:52 +0200

> off doing anything until the thaw.

No worries, thanks!

> https://github.com/mesonbuild/meson/blob/master/mesonbuild/environment.py#L183

I didn't either before writing the doc patch, which led me to
investigate why it *just works* when doing meson setup and then I saw
the 40 odd "Trying a default llvm-config fallback…" lines in
meson-log.txt =) 

-- 
Ole Peder Brandtzæg
It's raining triple sec in Tchula
and the radio plays "Crazy Train"

---

From: Tom Lane <[email-masked]>
Date: Sat, 18 May 2024 19:16:56 -0400

> off doing anything until the thaw.

FWIW, I don't think the release freeze precludes docs-only fixes.
But if you prefer to sit on this, that's fine too.

			regards, tom lane

---

From: Peter Eisentraut <[email-masked]>
Date: Wed, 21 Aug 2024 15:19:58 +0200

> updates the docs accordingly.

committed

---

From: Peter Eisentraut <[email-masked]>
Date: Wed, 21 Aug 2024 16:00:40 +0200

> Ahh, right, thanks!  I will look at committing your CI/fixup patches.

The CI images have been updated, so this should be ready to go now.  I 
gave the remaining two patches a try on CI, and it all looks okay to me. 
  (needed some gentle rebasing)

---

From: Peter Eisentraut <[email-masked]>
Date: Tue, 1 Oct 2024 06:23:41 -0400

>   (needed some gentle rebasing)

I have committed the two remaining patches.  I'll go nudge any affected 
buildfarm members to upgrade as needed.

---

From: Thomas Munro <[email-masked]>
Date: Wed, 2 Oct 2024 15:36:35 +1300

> buildfarm members to upgrade as needed.

Thanks!

FWIW next on my list of LLVM maintenance work are: fix ARM crash in
the next week or so (CF #5220), and figure out which patches need to
go where for JITLink, a small required API change for LLVM 20, unless
someone else is interested in working on that soon (there was a
patch[1] but the thread has gone quiet).

[1] https://www.postgresql.org/message-id/flat/20220829074622.2474104-1-alex.fan.q%40gmail.com