From 0e9ee191aab8c5d71569ee00831e9fff6f1225b1 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Wed, 25 Jun 2025 11:14:26 +0300
Subject: [PATCH v4 2/3] ci: meson: Explicitly enable meson features

By default, Meson silently disables features it cannot detect, which can
lead to incomplete builds. Explicitly enabling these features causes the
build to fail if they are missing, making such issues visible early.

Suggested-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/CAN55FZ0aO8d_jkyRijcGP8qO%3DXH09qG%3Dpw0ZZDvB4LMzuXYU1w%40mail.gmail.com
---
 .cirrus.tasks.yml | 108 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 90 insertions(+), 18 deletions(-)

diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index a7f75c5b59f..e8f5fee2627 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -31,6 +31,25 @@ env:
   TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
   PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth
 
+  # Meson feature flags, shared between all meson tasks except the
+  # 'SanityCheck' and 'Windows - VS' tasks
+  MESON_COMMON_FEATURES: >-
+    -Dauto_features=disabled
+    -Dldap=enabled
+    -Dssl=openssl
+    -Dtap_tests=enabled
+    -Dplperl=enabled
+    -Dplpython=enabled
+    -Ddocs=enabled
+    -Dicu=enabled
+    -Dlibxml=enabled
+    -Dlibxslt=enabled
+    -Dlz4=enabled
+    -Dpltcl=enabled
+    -Dreadline=enabled
+    -Dzlib=enabled
+    -Dzstd=enabled
+
 
 # What files to preserve in case tests fail
 on_failure_ac: &on_failure_ac
@@ -164,6 +183,15 @@ task:
       -c debug_parallel_query=regress
     PG_TEST_PG_UPGRADE_MODE: --link
 
+    MESON_FEATURES: >-
+      -Ddtrace=enabled
+      -Dgssapi=enabled
+      -Dlibcurl=enabled
+      -Dnls=enabled
+      -Dpam=enabled
+      -Dtcl_version=tcl86
+      -Duuid=bsd
+
   <<: *freebsd_task_template
 
   depends_on: SanityCheck
@@ -198,8 +226,8 @@ task:
       meson setup \
         --buildtype=debug \
         -Dcassert=true -Dinjection_points=true \
-        -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
         -Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
+        ${MESON_COMMON_FEATURES} ${MESON_FEATURES} \
         build
     EOF
   build_script: su postgres -c 'ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET}'
@@ -269,6 +297,12 @@ task:
         LC_ALL: "C"
         # -Duuid is not set for the NetBSD, see the comment below, above
         # configure_script, for more information.
+        MESON_FEATURES: >-
+          -Dgssapi=enabled
+          -Dlibcurl=enabled
+          -Dnls=enabled
+          -Dpam=enabled
+
       setup_additional_packages_script: |
         #pkgin -y install ...
       <<: *netbsd_task_template
@@ -279,8 +313,13 @@ task:
         OS_NAME: openbsd
         IMAGE_FAMILY: pg-ci-openbsd-postgres
         PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig'
-        UUID: -Duuid=e2fs
-        TCL: -Dtcl_version=tcl86
+
+        MESON_FEATURES: >-
+          -Dbsd_auth=enabled
+          -Dlibcurl=enabled
+          -Dtcl_version=tcl86
+          -Duuid=e2fs
+
       setup_additional_packages_script: |
         #pkg_add -I ...
       # Always core dump to ${CORE_DUMP_DIR}
@@ -317,7 +356,7 @@ task:
         --buildtype=debugoptimized \
         --pkg-config-path ${PKGCONFIG_PATH} \
         -Dcassert=true -Dinjection_points=true \
-        -Dssl=openssl ${UUID} ${TCL} \
+        ${MESON_COMMON_FEATURES} ${MESON_FEATURES} \
         build
     EOF
 
@@ -364,10 +403,6 @@ LINUX_CONFIGURE_FEATURES: &LINUX_CONFIGURE_FEATURES >-
   --with-uuid=ossp
   --with-zstd
 
-LINUX_MESON_FEATURES: &LINUX_MESON_FEATURES >-
-  -Dllvm=enabled
-  -Duuid=e2fs
-
 
 # Check SPECIAL in the matrix: below
 task:
@@ -408,7 +443,6 @@ task:
     LLVM_CONFIG: llvm-config-16
 
     LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
-    LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
 
   <<: *linux_task_template
 
@@ -502,12 +536,37 @@ task:
         PG_TEST_INITDB_EXTRA_OPTS: >-
           -c io_method=io_uring
 
+        LINUX_64_MESON_FEATURES: >-
+          -Ddocs_pdf=enabled
+          -Dgssapi=enabled
+          -Dlibcurl=enabled
+          -Dlibnuma=enabled
+          -Dliburing=enabled
+          -Dllvm=enabled
+          -Dnls=enabled
+          -Dpam=enabled
+          -Dplperl=enabled
+          -Dselinux=enabled
+          -Dsystemd=enabled
+          -Duuid=e2fs
+
+        LINUX_32_MESON_FEATURES: >-
+          -Ddocs_pdf=enabled
+          -Dgssapi=enabled
+          -Dlibcurl=enabled
+          -Dliburing=enabled
+          -Dnls=enabled
+          -Dpam=enabled
+          -Dselinux=enabled
+          -Dsystemd=enabled
+          -Duuid=e2fs
+
       configure_script: |
         su postgres <<-EOF
           meson setup \
             --buildtype=debug \
             -Dcassert=true -Dinjection_points=true \
-            ${LINUX_MESON_FEATURES} \
+            ${MESON_COMMON_FEATURES} ${LINUX_64_MESON_FEATURES} \
             build
         EOF
 
@@ -519,11 +578,9 @@ task:
           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.36-i386-linux-gnu \
-            -Dlibnuma=disabled \
+            ${MESON_COMMON_FEATURES} ${LINUX_32_MESON_FEATURES} \
             build-32
         EOF
 
@@ -587,6 +644,14 @@ task:
     CCACHE_DIR: ${HOME}/ccache
     MACPORTS_CACHE: ${HOME}/macports-cache
 
+    MESON_FEATURES: >-
+      -Dbonjour=enabled
+      -Ddtrace=enabled
+      -Dgssapi=enabled
+      -Dlibcurl=enabled
+      -Dnls=enabled
+      -Duuid=e2fs
+
     MACOS_PACKAGE_LIST: >-
       ccache
       icu
@@ -660,7 +725,7 @@ task:
       -Dextra_include_dirs=/opt/local/include \
       -Dextra_lib_dirs=/opt/local/lib \
       -Dcassert=true -Dinjection_points=true \
-      -Duuid=e2fs -Ddtrace=auto \
+      ${MESON_COMMON_FEATURES} ${MESON_FEATURES} \
       build
 
   build_script: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET}
@@ -715,6 +780,14 @@ task:
     # 0x8001 is SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX
     CIRRUS_WINDOWS_ERROR_MODE: 0x8001
 
+    MESON_FEATURES:
+      -Dauto_features=disabled
+      -Dldap=enabled
+      -Dssl=openssl
+      -Dtap_tests=enabled
+      -Dplperl=enabled
+      -Dplpython=enabled
+
   <<: *windows_task_template
 
   depends_on: SanityCheck
@@ -732,7 +805,7 @@ task:
   # Use /DEBUG:FASTLINK to avoid high memory usage during linking
   configure_script: |
     vcvarsall x64
-    meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% build
+    meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% %MESON_FEATURES% build
 
   build_script: |
     vcvarsall x64
@@ -790,9 +863,9 @@ task:
     %BASH% -c "where perl"
     %BASH% -c "perl --version"
 
-  # disable -Dnls as the number of files it creates cause a noticable slowdown
+  # -Dnls need to be disabled as the number of files it creates cause a noticable slowdown
   configure_script: |
-    %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Dinjection_points=true -Db_pch=true -Dnls=disabled -DTAR=%TAR% build"
+    %BASH% -c "meson setup -Ddebug=true -Doptimization=g -Dcassert=true -Dinjection_points=true -Db_pch=true %MESON_COMMON_FEATURES% -DTAR=%TAR% build"
 
   build_script: |
     %BASH% -c "ninja -C build ${MBUILD_TARGET}"
@@ -830,7 +903,6 @@ task:
     CCACHE_DIR: "/tmp/ccache_dir"
 
     LINUX_CONFIGURE_FEATURES: *LINUX_CONFIGURE_FEATURES
-    LINUX_MESON_FEATURES: *LINUX_MESON_FEATURES
 
     # GCC emits a warning for llvm-14, so switch to a newer one.
     LLVM_CONFIG: llvm-config-16
-- 
2.49.0

