From e58d68225de5d723851bfe04bf25ab1a0976e950 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Fri, 17 Jul 2026 16:05:44 +0300
Subject: [PATCH v15 4/5] Use .pc file as a standart extension build interface

---
 doc/src/sgml/extend.sgml         | 39 ++++++++++++++++----------------
 src/backend/jit/llvm/meson.build |  2 +-
 src/backend/meson.build          | 20 ++++++++--------
 3 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index ac7c2e54d2f..80db1cc2034 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -1455,10 +1455,10 @@ include $(PGXS)
     When <productname>PostgreSQL</productname> is built with
     <productname>Meson</productname>, it also installs a
     <literal>pkg-config</literal> file,
-    <literal>postgresql-&majorversion;-llvm-jit-bitcode.pc</literal>
-    (<xref linkend="extend-pkg-config"/>).  This file is used internally to
-    emit <acronym>LLVM</acronym> <acronym>JIT</acronym> bitcode; it is not
-    (yet) a stable, supported interface for building extensions.
+    <literal>postgresql-&majorversion;-extension.pc</literal>
+    (<xref linkend="extend-pkg-config"/>).  This file collects the
+    compilation flags needed to build server code, so that extensions built
+    with <productname>Meson</productname> can compile against the server.
    </para>
 
   </sect1>
@@ -1943,35 +1943,36 @@ make VPATH=/path/to/extension/source/tree install
   </sect1>
 
   <sect1 id="extend-pkg-config">
-   <title>postgresql-&majorversion;-llvm-jit-bitcode.pc</title>
+   <title>postgresql-&majorversion;-extension.pc</title>
 
    <para>
     When <productname>PostgreSQL</productname> is built with
     <productname>Meson</productname>, it installs a
     <literal>pkg-config</literal> file named
-    <literal>postgresql-&majorversion;-llvm-jit-bitcode.pc</literal>.  It is
-    used internally to emit <acronym>LLVM</acronym> <acronym>JIT</acronym>
-    bitcode for the server and for selected
-    <filename>contrib</filename> modules, and it collects the same
-    compilation flags that are used to build the server itself.
+    <literal>postgresql-&majorversion;-extension.pc</literal>.  It provides
+    the same compilation flags that are used to build the server itself, so
+    that extensions can be built with <productname>Meson</productname>
+    against a given <productname>PostgreSQL</productname> installation.  It is
+    also used internally to emit <acronym>LLVM</acronym> <acronym>JIT</acronym>
+    bitcode for the server and for selected <filename>contrib</filename>
+    modules.
    </para>
 
    <para>
-    The file is deliberately versioned and named after its bitcode purpose
-    because there is not yet agreement on a stable, general-purpose interface
-    for building extensions.  It is therefore <emphasis>not</emphasis> a
-    supported replacement for <acronym>PGXS</acronym>
-    (<xref linkend="extend-pgxs"/>), and its name and contents may change
-    between major releases.
+    The file is versioned by major release, so an extension can build against
+    a specific <productname>PostgreSQL</productname> major version.  It offers
+    a <productname>Meson</productname>-based alternative to
+    <acronym>PGXS</acronym> (<xref linkend="extend-pgxs"/>), which uses
+    <application>make</application>.
    </para>
 
    <para>
     To use the
-    <literal>postgresql-&majorversion;-llvm-jit-bitcode.pc</literal>
+    <literal>postgresql-&majorversion;-extension.pc</literal>
     infrastructure for your extension, you must write a simple
     <filename>meson.build</filename> file. In the
     <filename>meson.build</filename> file, you need to include the
-    <literal>postgresql-&majorversion;-llvm-jit-bitcode.pc</literal>
+    <literal>postgresql-&majorversion;-extension.pc</literal>
     <literal>pkg-config</literal> file. Here is an example that builds an
     extension module named <literal>isbn_issn</literal>, consisting of a
     shared library containing some C code, an extension control file, an
@@ -1981,7 +1982,7 @@ make VPATH=/path/to/extension/source/tree install
 <programlisting>
 project('isbn_issn', 'c')
 
-pg_ext = dependency('postgresql-&majorversion;-llvm-jit-bitcode-warnings')
+pg_ext = dependency('postgresql-&majorversion;-extension-warnings')
 
 isbn_issn_sources = files('isbn_issn.c')
 
diff --git a/src/backend/jit/llvm/meson.build b/src/backend/jit/llvm/meson.build
index c3b5464f8c1..1d7d1038668 100644
--- a/src/backend/jit/llvm/meson.build
+++ b/src/backend/jit/llvm/meson.build
@@ -91,6 +91,6 @@ backend_targets += llvmjit_types
 # dependencies
 pkg_config = find_program(['pkg-config', 'pkgconf'], required: true)
 r = run_command(pkg_config,
-  ['--cflags-only-I', meson.project_build_root() / 'meson-uninstalled/postgresql-@0@-llvm-jit-bitcode-uninstalled.pc'.format(pg_version_major)],
+  ['--cflags-only-I', meson.project_build_root() / 'meson-uninstalled/postgresql-@0@-extension-uninstalled.pc'.format(pg_version_major)],
   check: true)
 bitcode_cflags += r.stdout().split()
diff --git a/src/backend/meson.build b/src/backend/meson.build
index f6f41dc144c..2c52a6648d2 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -223,12 +223,12 @@ pg_test_mod_args = pg_mod_args + {
 
 
 ###############################################################
-# Define a .pc file used when emitting LLVM JIT bitcode
+# Define a .pc file for building extensions (also used
+# internally when emitting LLVM JIT bitcode)
 ###############################################################
 
-# Versioned name, so we don't claim a too-general name before there's
-# agreement on a stable interface for building extensions.
-pg_bitcode_pc_name = 'postgresql-@0@-llvm-jit-bitcode'.format(pg_version_major)
+# Versioned name, so extensions can build against a specific major version.
+pg_ext_pc_name = 'postgresql-@0@-extension'.format(pg_version_major)
 
 pg_ext_vars = []
 pg_ext_vars_inst = []
@@ -324,10 +324,10 @@ if mod_link_args_fmt.length() != 0
   endforeach
 endif
 
-# main .pc used to emit LLVM JIT bitcode
+# main .pc used to build extensions (and internally to emit LLVM JIT bitcode)
 pkgconfig.generate(
-  name: pg_bitcode_pc_name,
-  description: 'PostgreSQL LLVM JIT Bitcode Support',
+  name: pg_ext_pc_name,
+  description: 'PostgreSQL Extension Build Support',
   url: pg_url,
 
   subdirs: pg_ext_subdirs,
@@ -340,9 +340,9 @@ pkgconfig.generate(
 
 # a .pc depending on the above, but with all our warnings enabled
 pkgconfig.generate(
-  name: pg_bitcode_pc_name + '-warnings',
-  description: 'PostgreSQL LLVM JIT Bitcode Support with compiler warnings the same as core code',
-  requires: pg_bitcode_pc_name,
+  name: pg_ext_pc_name + '-warnings',
+  description: 'PostgreSQL Extension Build Support with compiler warnings the same as core code',
+  requires: pg_ext_pc_name,
   url: pg_url,
   extra_cflags: pg_ext_cflags_warn,
 
-- 
2.47.3

