This has been an open task in the move from autoconf to meson. It's been discussed a few times here and there across various threads, but it's gotten a bit confusing, so I'm starting a fresh thread.

The holdup was that the headerscheck target was not ported to meson. This was done a few months ago. So converting the CI job to meson is now somewhat straightforward. Here are some patches.

(I found some existing partial work in public git branches from Andres, of which I have integrated a few bits here.)

I've tried to be careful to maintain the scope of each individual build step (e.g., what features it enables, what optimization level it uses).

One thing we're losing is the sharing of the configure cache between the steps (gcc.cache, clang.cache). There is a way to do that in meson (meson-private/coredata.dat), but it's not meant to be used across different build directories, and so we would have to restructure some of this a bit differently, I think, so I stayed away from that for now.

The branch from Andres mentioned above was keen to enable PCH for the mingw cross build for better performance. I have added that here as a separate patch.

I've done a few rounds of testing and it all seems quite fast, but obviously that depends on caching, time of day, and so on, so more testing is welcome.
From c511ff0fceaf8befd53d41ed6ce08172710a1656 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 24 Sep 2026 16:32:23 +0200
Subject: [PATCH 1/3] Add missing dependencies to meson headerscheck target

These checks compile headers, so all the headers they might include
need to have been generated.  The makefile target does that, but the
meson implementation didn't do that.  (Arguably a bit of a bug in
commit e82fc27e095.)  Add the required dependencies so that meson
compile headerscheck works in an unbuilt tree as well (as is
documented).
---
 meson.build | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index f4cde249242..2993c568680 100644
--- a/meson.build
+++ b/meson.build
@@ -4131,12 +4131,24 @@ add_test_setup('running',
 ###############################################################
 
 headerscheck = files('src/tools/pginclude/headerscheck')
+
+# These checks compile headers, so all the headers they might include
+# need to have been generated.
+headerscheck_depends = [
+  generated_headers_stamp,
+  generated_backend_headers_stamp,
+  backend_parser,
+  jsonpath_gram,
+]
+
 run_target('headerscheck',
-  command: [headerscheck, meson.project_source_root(), 
meson.project_build_root()]
+  command: [headerscheck, meson.project_source_root(), 
meson.project_build_root()],
+  depends: headerscheck_depends,
 )
 
 run_target('cpluspluscheck',
-  command: [headerscheck, '--cplusplus', meson.project_source_root(), 
meson.project_build_root()]
+  command: [headerscheck, '--cplusplus', meson.project_source_root(), 
meson.project_build_root()],
+  depends: headerscheck_depends,
 )
 
 

base-commit: 4545cee303c257e58195e3d033c05bf38e2cd4d6
-- 
2.55.0

From ce2fd5b8f36ffe2adb40ec598b568589c674fd17 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 24 Sep 2026 16:32:19 +0200
Subject: [PATCH 2/3] ci: Convert CompilerWarnings job to meson

---
 .github/workflows/pg-ci.yml       | 80 +++++++++++++++++--------------
 src/tools/ci/mingw-cross-file.txt | 22 +++++++++
 2 files changed, 67 insertions(+), 35 deletions(-)
 create mode 100644 src/tools/ci/mingw-cross-file.txt

diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml
index a2629c8335a..e80e2c9efbd 100644
--- a/.github/workflows/pg-ci.yml
+++ b/.github/workflows/pg-ci.yml
@@ -94,7 +94,7 @@ env:
     -Dzlib=enabled
     -Dzstd=enabled
 
-  # Shared between the Linux autoconf job and the CompilerWarnings jobs
+  # Used by the Linux autoconf job
   LINUX_CONFIGURE_FEATURES: >-
     --with-gssapi
     --with-icu
@@ -1151,10 +1151,6 @@ jobs:
   # with various combinations of cassert/dtrace flags. Trace probes have
   # a history of getting accidentally broken; the matrix is there to
   # catch that.
-  #
-  # The autoconf cache files (gcc.cache / clang.cache) are intentionally
-  # reused across the matrix entries that share a compiler, so we don't
-  # pay for full feature detection on every entry.
   compiler-warnings:
     name: CompilerWarnings
     needs: [setup, sanity-check]
@@ -1170,7 +1166,17 @@ jobs:
       # Use larger ccache cache as this job compiles with multiple
       # compilers / flag combinations.
       CCACHE_MAXSIZE: "1G"
-      DEFAULT_BUILD: world-bin
+
+      # Enable everything else in LINUX_CONFIGURE_FEATURES but not in
+      # MESON_COMMON_FEATURES.
+      MESON_FEATURES: >-
+        -Dgssapi=enabled
+        -Dlibcurl=enabled
+        -Dllvm=enabled
+        -Dpam=enabled
+        -Dselinux=enabled
+        -Dsystemd=enabled
+        -Duuid=ossp
 
     steps:
       - *nix_sysinfo_step
@@ -1178,33 +1184,31 @@ jobs:
       - *ccache_restore_default_step
       - *ccache_restore_branch_step
 
-      - name: Setup workspace
-        run: |
-          echo "COPT=-Werror" > src/Makefile.custom
-
       # gcc, cassert off, dtrace on
       - name: gcc warnings + (dtrace)
         if: ${{ !cancelled() }}
         env:
-          CONF: ${{env.LINUX_CONFIGURE_FEATURES}} --cache gcc.cache 
--enable-dtrace
+          CONF: ${{env.MESON_COMMON_FEATURES}} ${{env.MESON_FEATURES}} 
-Ddtrace=enabled
           CC: ccache gcc
           CXX: ccache g++
-          CLANG: ccache clang
         run: &compiler_warnings_cmd |
           echo "::group::configure"
-          ./configure \
+          rm -rf build
+          meson setup \
+            -Dauto_features=disabled \
+            -Dwerror=true \
+            -Ddebug=false \
             ${{env.CONF}} \
-            CLANG="ccache clang"
+            build
           echo "::endgroup::"
 
-          make -s -j${{env.BUILD_JOBS}} clean
-          make -s -j${{env.BUILD_JOBS}} ${{env.DEFAULT_BUILD}}
+          ninja -C build --quiet -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}}
 
       # gcc, cassert on, dtrace off
       - name: gcc warnings + (cassert)
         if: ${{ !cancelled() }}
         env:
-          CONF: ${{env.LINUX_CONFIGURE_FEATURES}} --cache gcc.cache 
--enable-cassert
+          CONF: ${{env.MESON_COMMON_FEATURES}} ${{env.MESON_FEATURES}} 
-Dcassert=true
           CC: ccache gcc
           CXX: ccache g++
         run: *compiler_warnings_cmd
@@ -1213,7 +1217,7 @@ jobs:
       - name: clang warnings
         if: ${{ !cancelled() }}
         env:
-          CONF: ${{env.LINUX_CONFIGURE_FEATURES}} --cache clang.cache
+          CONF: ${{env.MESON_COMMON_FEATURES}} ${{env.MESON_FEATURES}}
           CC: ccache clang
           CXX: ccache clang++
         run: *compiler_warnings_cmd
@@ -1222,7 +1226,7 @@ jobs:
       - name: clang warnings + (cassert + dtrace)
         if: ${{ !cancelled() }}
         env:
-          CONF: ${{env.LINUX_CONFIGURE_FEATURES}} --cache clang.cache 
--enable-cassert --enable-dtrace
+          CONF: ${{env.MESON_COMMON_FEATURES}} ${{env.MESON_FEATURES}} 
-Dcassert=true -Ddtrace=enabled
           CC: ccache clang
           CXX: ccache clang++
         run: *compiler_warnings_cmd
@@ -1230,9 +1234,10 @@ jobs:
       - name: mingw warnings (cross compilation)
         if: ${{ !cancelled() }}
         env:
-          CONF: --host=x86_64-w64-mingw32ucrt --enable-cassert --without-icu
-          CC: ccache x86_64-w64-mingw32ucrt-gcc
-          CXX: ccache x86_64-w64-mingw32ucrt-g++
+          CONF: >-
+            --cross-file src/tools/ci/mingw-cross-file.txt
+            -Dcassert=true
+          MBUILD_TARGET: all
         run: *compiler_warnings_cmd
 
       ###
@@ -1242,34 +1247,39 @@ jobs:
       - name: Build documentation
         if: ${{ !cancelled() }}
         env:
-          CONF: --cache gcc.cache
+          CONF: -Ddocs=enabled
           CC: ccache gcc
           CXX: ccache g++
-          DEFAULT_BUILD: -C doc
+          MBUILD_TARGET: docs
         run: *compiler_warnings_cmd
 
       ###
       # Verify headerscheck / cpluspluscheck succeed
       #
-      # - Run both in same script to increase parallelism, use -k to get
-      #   result of both
+      # - Run both in the same ninja invocation to increase parallelism, use
+      #   -k 0 to get the result of both
       # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose
       ###
       - name: headerscheck + cpluspluscheck
         if: ${{ !cancelled() }}
+        env:
+          CONF: ${{env.MESON_COMMON_FEATURES}} ${{env.MESON_FEATURES}}
+          CC: ccache gcc
+          CXX: ccache g++
+          EXTRAFLAGS: -fmax-errors=10
         run: |
           echo "::group::configure"
-          ./configure \
-            ${{env.LINUX_CONFIGURE_FEATURES}} \
-            --cache gcc.cache \
-            --quiet \
-            CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
+          rm -rf build
+          meson setup \
+            -Dauto_features=disabled \
+            -Dwerror=true \
+            -Ddebug=false \
+            ${{env.CONF}} \
+            build
           echo "::endgroup::"
 
-          make -s -j${{env.BUILD_JOBS}} clean
-          make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \
-            headerscheck cpluspluscheck \
-            EXTRAFLAGS='-fmax-errors=10'
+          ninja -C build --quiet -j${{env.BUILD_JOBS}} -k 0 \
+            headerscheck cpluspluscheck
 
       - *ccache_decide_save_step
       - *ccache_save_step
diff --git a/src/tools/ci/mingw-cross-file.txt 
b/src/tools/ci/mingw-cross-file.txt
new file mode 100644
index 00000000000..413e3d3a489
--- /dev/null
+++ b/src/tools/ci/mingw-cross-file.txt
@@ -0,0 +1,22 @@
+# Meson cross file for cross compiling to Windows with the Debian
+# mingw-w64 toolchain, as used by the CompilerWarnings CI job.
+#
+# ccache is spelled out here because meson's automatic ccache
+# detection does not apply to compilers that are named in a cross
+# file.
+
+[constants]
+prefix = 'x86_64-w64-mingw32ucrt-'
+
+[binaries]
+c = ['ccache', prefix + 'gcc']
+cpp = ['ccache', prefix + 'g++']
+ar = prefix + 'ar'
+strip = prefix + 'strip'
+windres = prefix + 'windres'
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86_64'
+cpu = 'x86_64'
+endian = 'little'
-- 
2.55.0

From ab73ead9a46c3257a9886150565106e425825941 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 24 Sep 2026 16:38:41 +0200
Subject: [PATCH 3/3] ci: Enable PCH in mingw cross job

---
 .github/workflows/pg-ci.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml
index e80e2c9efbd..a6d34909515 100644
--- a/.github/workflows/pg-ci.yml
+++ b/.github/workflows/pg-ci.yml
@@ -1166,6 +1166,8 @@ jobs:
       # Use larger ccache cache as this job compiles with multiple
       # compilers / flag combinations.
       CCACHE_MAXSIZE: "1G"
+      CCACHE_SLOPPINESS: pch_defines,time_macros
+      CCACHE_DEPEND: 1
 
       # Enable everything else in LINUX_CONFIGURE_FEATURES but not in
       # MESON_COMMON_FEATURES.
@@ -1236,6 +1238,7 @@ jobs:
         env:
           CONF: >-
             --cross-file src/tools/ci/mingw-cross-file.txt
+            -Db_pch=true
             -Dcassert=true
           MBUILD_TARGET: all
         run: *compiler_warnings_cmd
-- 
2.55.0

Reply via email to