From bd5fa65f2c9fbc3715382f2bb26d546ef3981729 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Wed, 28 Sep 2022 19:54:59 -0500
Subject: [PATCH 4/4] s!convert to meson

Note that PCH causes gcc to crash:
https://cirrus-ci.com/task/5856316085239808

https://cirrus-ci.com/task/5982327657463808
https://community.chocolatey.org/packages/Cygwin#versionhistory
a semi-relevant message about msys(not cygwin): https://www.postgresql.org/message-id/9f4f22be-f9f1-b350-bc06-521226b87f7a%40dunslane.net

ci-os-only: cygwin
---
 .cirrus.yml                     | 29 +++++++++++++++++------------
 src/tools/ci/cores_backtrace.sh |  4 ++--
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index cd4cbf9e5ed..006058a09b0 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -43,6 +43,7 @@ on_failure_meson: &on_failure_meson
       - "build*/testrun/**/*.log"
       - "build*/testrun/**/*.diffs"
       - "build*/testrun/**/regress_log_*"
+      - "**/*.stackdump"
     type: text/plain
 
   # In theory it'd be nice to upload the junit files meson generates, so that
@@ -480,30 +481,35 @@ task:
 task:
   name: Windows - Cygwin
   #XXX only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*'
+  only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*'
   timeout_in: 90m
 
   env:
     CPUS: 4
-    BUILD_JOBS: 4
-    TEST_JOBS: 1
+    BUILD_JOBS: $CPUS
+    TEST_JOBS: $CPUS
     CCACHE_DIR: /tmp/ccache
-    CONFIGURE_FLAGS: --enable-debug --enable-tap-tests --with-ldap --with-ssl=openssl --with-libxml --enable-cassert
-    # --with-gssapi
-    CONFIGURE_CACHE: /tmp/ccache/configure.cache
+    CCACHE_DEPEND: 1
+    # compress because PCH are huge
+    CCACHE_COMPRESS: 1
+    # Actually, do not use ccache for PCH ... it crashes gcc
+    #CCACHE_SLOPPINESS: pch_defines,time_macros,include_file_ctime,include_file_mtime
     PG_TEST_USE_UNIX_SOCKETS: 1
     CCACHE_LOGFILE: ccache.log
     EXTRA_REGRESS_OPTS: --max-connections=1
     PG_TEST_EXTRA: ldap ssl # disable kerberos
+    CFLAGS: -Og -ggdb
 
   windows_container:
-    image: cirrusci/windowsservercore:2019
+    image: cirrusci/windowsservercore:2019-2022.06.23
     os_version: 2019
     cpu: $CPUS
     memory: 4G
 
   setup_additional_packages_script: |
     choco install -y --no-progress cygwin
-    C:\tools\cygwin\cygwinsetup.exe -q -P cygrunsrv,make,gcc-core,ccache,binutils,libtool,pkg-config,flex,bison,zlib-devel,libxml2-devel,libxslt-devel,libssl-devel,openldap-devel,libreadline-devel,perl,perl-IPC-Run
+    C:\tools\cygwin\cygwinsetup.exe -q -P cygrunsrv,make,gcc-core,ccache,binutils,libtool,pkg-config,flex,bison,zlib-devel,libxml2-devel,libxslt-devel,libssl-devel,openldap-devel,libreadline-devel,perl,meson,ninja
+    REM perl-IPC-Run,
     REM libkrb5-devel,krb5-server
     C:\tools\cygwin\bin\bash.exe --login -c "cygserver-config -y"
     C:\tools\cygwin\bin\bash.exe --login -c "echo 'kern.ipc.semmni 1024' >> /etc/cygserver.conf"
@@ -521,21 +527,20 @@ task:
     folder: C:\tools\cygwin\tmp\ccache
 
   configure_script:
-    # Try to configure with the cache file, and retry without if it fails, in case the flags changed.
-    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && for i in 1 2; do ./configure --cache-file=${CONFIGURE_CACHE} ${CONFIGURE_FLAGS} CC='ccache gcc' CFLAGS='-Og -ggdb' && break; rm -v ${CONFIGURE_CACHE}; done"
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && meson setup --buildtype=debug -Dcassert=true -Db_pch=false -Dssl=openssl -Duuid=e2fs -Dtap_tests=disabled -DPG_TEST_EXTRA='$PG_TEST_EXTRA' build"
 
   build_script:
-    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && make -s -j ${BUILD_JOBS} world-bin"
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && ninja -C build -j${BUILD_JOBS}"
     - C:\tools\cygwin\bin\bash.exe --login -c "ccache --show-stats"
 
   always:
     upload_caches: ccache
 
   test_world_script:
-    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 77m make -s -j ${TEST_JOBS} ${CHECK} PROVE_FLAGS='-j2 --timer' ${CHECKFLAGS}"
+    - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && meson test $MTEST_ARGS --num-processes ${TEST_JOBS}"
 
   on_failure:
-    <<: *on_failure
+    <<: *on_failure_meson
     cores_script:
       - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && src/tools/ci/cores_backtrace.sh cygwin ."
 
diff --git a/src/tools/ci/cores_backtrace.sh b/src/tools/ci/cores_backtrace.sh
index 27f93147e4e..1e593429946 100755
--- a/src/tools/ci/cores_backtrace.sh
+++ b/src/tools/ci/cores_backtrace.sh
@@ -23,8 +23,8 @@ case $os in
             binary=`basename "$stack" .stackdump`
             echo;echo;
             echo "dumping ${stack} for ${binary}"
-            #awk '/^0/{print $2}' $stack |addr2line -f -i -e "./src/backend/$binary.exe"
-            awk '/^0/{print $2}' $stack |addr2line -f -i -e src/backend/postgres.exe
+            #awk '/^0/{print $2}' $stack |addr2line -f -i -e "./build/src/backend/$binary.exe"
+            awk '/^0/{print $2}' $stack |addr2line -f -i -e ./build/tmp_install/usr/local/pgsql/bin/postgres.exe
         done
         exit 0
         ;;
-- 
2.25.1

