From e58d68225de5d723851bfe04bf25ab1a0976e950 Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz 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 PostgreSQL is built with Meson, it also installs a pkg-config file, - postgresql-&majorversion;-llvm-jit-bitcode.pc - (). This file is used internally to - emit LLVM JIT bitcode; it is not - (yet) a stable, supported interface for building extensions. + postgresql-&majorversion;-extension.pc + (). This file collects the + compilation flags needed to build server code, so that extensions built + with Meson can compile against the server. @@ -1943,35 +1943,36 @@ make VPATH=/path/to/extension/source/tree install - postgresql-&majorversion;-llvm-jit-bitcode.pc + postgresql-&majorversion;-extension.pc When PostgreSQL is built with Meson, it installs a pkg-config file named - postgresql-&majorversion;-llvm-jit-bitcode.pc. It is - used internally to emit LLVM JIT - bitcode for the server and for selected - contrib modules, and it collects the same - compilation flags that are used to build the server itself. + postgresql-&majorversion;-extension.pc. It provides + the same compilation flags that are used to build the server itself, so + that extensions can be built with Meson + against a given PostgreSQL installation. It is + also used internally to emit LLVM JIT + bitcode for the server and for selected contrib + modules. - 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 not a - supported replacement for 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 PostgreSQL major version. It offers + a Meson-based alternative to + PGXS (), which uses + make. To use the - postgresql-&majorversion;-llvm-jit-bitcode.pc + postgresql-&majorversion;-extension.pc infrastructure for your extension, you must write a simple meson.build file. In the meson.build file, you need to include the - postgresql-&majorversion;-llvm-jit-bitcode.pc + postgresql-&majorversion;-extension.pc pkg-config file. Here is an example that builds an extension module named isbn_issn, 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 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