On Thu, Oct 20, 2022 at 10:40:40PM -0500, Justin Pryzby wrote: > On Thu, Aug 04, 2022 at 04:16:06PM +1200, Thomas Munro wrote: > > On Thu, Aug 4, 2022 at 3:38 PM Justin Pryzby <pry...@telsasoft.com> wrote: > > > [train wreck] > > > > Oh my, so I'm getting the impression we might actually be totally > > unstable on Cygwin. Which surprises me because ... wait a minute ... > > lorikeet isn't even running most of the tests. So... we don't really > > know the degree to which any of this works at all? > > Right. > > Maybe it's of limited interest, but .. > > This updates the patch to build and test with meson. > Which first requires patching some meson.builds. > I guess that's needed for some current BF members, too. > Unfortunately, ccache+PCH causes gcc to crash :(
Resending with the 'only-if' line commented (doh). And some fixes to 001 as Andres pointed out by on other thread. -- Justin
>From 2741472080eceac5cb6d002c39eaf319d7f72b50 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Fri, 30 Sep 2022 13:39:43 -0500 Subject: [PATCH 1/3] meson: other fixes for cygwin XXX: what about HAVE_BUGGY_STRTOF ? See: 20221021034040.gt16...@telsasoft.com --- meson.build | 8 ++++++-- src/port/meson.build | 4 ++++ src/test/regress/meson.build | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index ce2f223a409..ed24370672a 100644 --- a/meson.build +++ b/meson.build @@ -211,6 +211,10 @@ if host_system == 'aix' elif host_system == 'cygwin' cppflags += '-D_GNU_SOURCE' + dlsuffix = '.dll' + mod_link_args_fmt = ['@0@'] + mod_link_with_name = 'lib@0@.exe.a' + mod_link_with_dir = 'libdir' elif host_system == 'darwin' dlsuffix = '.dylib' @@ -2301,8 +2305,8 @@ gnugetopt_dep = cc.find_library('gnugetopt', required: false) # (i.e., allow '-' as a flag character), so use our version on those platforms # - We want to use system's getopt_long() only if the system provides struct # option -always_replace_getopt = host_system in ['windows', 'openbsd', 'solaris'] -always_replace_getopt_long = host_system == 'windows' or not cdata.has('HAVE_STRUCT_OPTION') +always_replace_getopt = host_system in ['windows', 'cygwin', 'openbsd', 'solaris'] +always_replace_getopt_long = host_system in ['windows', 'cygwin'] or not cdata.has('HAVE_STRUCT_OPTION') # Required on BSDs execinfo_dep = cc.find_library('execinfo', required: false) diff --git a/src/port/meson.build b/src/port/meson.build index c2222696f1b..0ba83cc7930 100644 --- a/src/port/meson.build +++ b/src/port/meson.build @@ -40,6 +40,10 @@ if host_system == 'windows' 'win32setlocale.c', 'win32stat.c', ) +elif host_system == 'cygwin' + pgport_sources += files( + 'dirmod.c', + ) endif if cc.get_id() == 'msvc' diff --git a/src/test/regress/meson.build b/src/test/regress/meson.build index f1adcd9198c..72a23737fa7 100644 --- a/src/test/regress/meson.build +++ b/src/test/regress/meson.build @@ -12,6 +12,8 @@ regress_sources = pg_regress_c + files( host_tuple_cc = cc.get_id() if host_system == 'windows' and host_tuple_cc == 'gcc' host_tuple_cc = 'mingw' +elif host_system == 'cygwin' and host_tuple_cc == 'gcc' + host_tuple_cc = 'cygwin' endif host_tuple = '@0@-@1@-@2@'.format(host_cpu, host_system, host_tuple_cc) -- 2.25.1
>From 8f31be4d0bf036df890e32568dbc056c36fd57c5 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.mu...@gmail.com> Date: Mon, 25 Jul 2022 23:05:10 +1200 Subject: [PATCH 2/3] WIP CI support for Cygwin. ci-os-only: cygwin See also: d8e78714-dc77-4a64-783f-e863ba4d9...@2ndquadrant.com https://cirrus-ci.com/task/5145086722834432 XXX This should use a canned Docker image with all the right packages installed? But if the larger image is slower to start, then maybe not... --- .cirrus.yml | 76 +++++++++++++++++++++++ configure | 2 +- configure.ac | 2 +- src/test/perl/PostgreSQL/Test/Cluster.pm | 4 +- src/test/perl/PostgreSQL/Test/Utils.pm | 12 +++- src/test/recovery/t/020_archive_status.pl | 2 +- src/tools/ci/cores_backtrace.sh | 33 +++++++++- src/tools/ci/pg_ci_base.conf | 2 + 8 files changed, 122 insertions(+), 11 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 9f2282471a9..02b0f3b7045 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -464,6 +464,82 @@ task: type: text/plain +task: + name: Windows - Cygwin + only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*' + #XXX only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*' + timeout_in: 90m + + env: + CPUS: 4 + BUILD_JOBS: 4 + TEST_JOBS: 1 + CCACHE_DIR: /tmp/ccache + CCACHE_LOGFILE: ccache.log + CONFIGURE_FLAGS: --enable-cassert --enable-debug --with-ldap --with-ssl=openssl --with-libxml + # --enable-tap-tests + # --disable-dynamicbase + # --with-gssapi + CONFIGURE_CACHE: /tmp/ccache/configure.cache + PG_TEST_USE_UNIX_SOCKETS: 1 + EXTRA_REGRESS_OPTS: --max-connections=1 + PG_TEST_EXTRA: ldap ssl # disable kerberos + + windows_container: + 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 + 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" + C:\tools\cygwin\bin\bash.exe --login -c "echo 'kern.ipc.semmns 1024' >> /etc/cygserver.conf" + C:\tools\cygwin\bin\bash.exe --login -c "net start cygserver" + + sysinfo_script: | + chcp + systeminfo + powershell -Command get-psdrive -psprovider filesystem + set + C:\tools\cygwin\bin\bash.exe --login -c "id; uname -a; ulimit -a -H; ulimit -a -S; export" + + ccache_cache: + folder: C:\tools\cygwin\tmp\ccache + fingerprint_key: ccache/cygwin + reupload_on_changes: true + + 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" + + build_script: + #- C:\tools\cygwin\bin\bash.exe --login -c "ccache --max-size ${CCACHE_MAXSIZE}" + - C:\tools\cygwin\bin\bash.exe --login -c "ccache --zero-stats" + - 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 "ccache --show-stats" + + upload_caches: ccache + + test_world_script: + #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/subscription" + #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/recovery" + - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/modules/test_misc" + - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/interfaces/libpq" + - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/bin/psql" + #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s check ${CHECKFLAGS} -C src/bin -j 2" + - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 77m make -s -j ${TEST_JOBS} ${CHECK} PROVE_FLAGS='-j2 --timer' ${CHECKFLAGS}" + + on_failure: + <<: *on_failure_ac + cores_script: + - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && src/tools/ci/cores_backtrace.sh cygwin ." + + task: name: CompilerWarnings diff --git a/configure b/configure index 3966368b8d9..68e366dcfc2 100755 --- a/configure +++ b/configure @@ -16494,7 +16494,7 @@ fi # mingw has adopted a GNU-centric interpretation of optind/optreset, # so always use our version on Windows. -if test "$PORTNAME" = "win32"; then +if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then case " $LIBOBJS " in *" getopt.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt.$ac_objext" diff --git a/configure.ac b/configure.ac index f76b7ee31fc..33c5475520e 100644 --- a/configure.ac +++ b/configure.ac @@ -1878,7 +1878,7 @@ fi # mingw has adopted a GNU-centric interpretation of optind/optreset, # so always use our version on Windows. -if test "$PORTNAME" = "win32"; then +if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then AC_LIBOBJ(getopt) AC_LIBOBJ(getopt_long) fi diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index d80134b26f3..5b5e8e67137 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -1052,7 +1052,7 @@ sub enable_restoring # the path contains spaces. $path =~ s{\\}{\\\\}g if ($PostgreSQL::Test::Utils::windows_os); my $copy_command = - $PostgreSQL::Test::Utils::windows_os + $PostgreSQL::Test::Utils::windows_os && !$PostgreSQL::Test::Utils::is_cygwin ? qq{copy "$path\\\\%f" "%p"} : qq{cp "$path/%f" "%p"}; @@ -1122,7 +1122,7 @@ sub enable_archiving # the path contains spaces. $path =~ s{\\}{\\\\}g if ($PostgreSQL::Test::Utils::windows_os); my $copy_command = - $PostgreSQL::Test::Utils::windows_os + $PostgreSQL::Test::Utils::windows_os && !$PostgreSQL::Test::Utils::is_cygwin ? qq{copy "%p" "$path\\\\%f"} : qq{cp "%p" "$path/%f"}; diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm index 99d33451064..fb7fca57239 100644 --- a/src/test/perl/PostgreSQL/Test/Utils.pm +++ b/src/test/perl/PostgreSQL/Test/Utils.pm @@ -88,10 +88,11 @@ our @EXPORT = qw( $windows_os $is_msys2 + $is_cygwin $use_unix_sockets ); -our ($windows_os, $is_msys2, $use_unix_sockets, $timeout_default, +our ($windows_os, $is_msys2, $is_cygwin, $use_unix_sockets, $timeout_default, $tmp_check, $log_path, $test_logfile); BEGIN @@ -140,13 +141,18 @@ BEGIN $ENV{PGAPPNAME} = basename($0); # Must be set early - $windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys'; + $windows_os = $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys' || + $Config{osname} eq 'cygwin'; + # Check if this environment is MSYS2. $is_msys2 = $windows_os && -x '/usr/bin/uname' && `uname -or` =~ /^[2-9].*Msys/; + # Check if this environment is Cygwin + $is_cygwin = $Config{osname} eq 'cygwin'; + if ($windows_os) { require Win32API::File; @@ -707,7 +713,7 @@ sub dir_symlink { my $oldname = shift; my $newname = shift; - if ($windows_os) + if ($windows_os && !$is_cygwin) { $oldname =~ s,/,\\,g; $newname =~ s,/,\\,g; diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl index fe9ac06b32d..63452b49bd3 100644 --- a/src/test/recovery/t/020_archive_status.pl +++ b/src/test/recovery/t/020_archive_status.pl @@ -26,7 +26,7 @@ my $primary_data = $primary->data_dir; # a portable solution, use an archive command based on a command known to # work but will fail: copy with an incorrect original path. my $incorrect_command = - $PostgreSQL::Test::Utils::windows_os + $PostgreSQL::Test::Utils::windows_os && !$PostgreSQL::Test::Utils::is_cygwin ? qq{copy "%p_does_not_exist" "%f_does_not_exist"} : qq{cp "%p_does_not_exist" "%f_does_not_exist"}; $primary->safe_psql( diff --git a/src/tools/ci/cores_backtrace.sh b/src/tools/ci/cores_backtrace.sh index 28d3cecfc67..02bd50b10fa 100755 --- a/src/tools/ci/cores_backtrace.sh +++ b/src/tools/ci/cores_backtrace.sh @@ -1,5 +1,8 @@ #! /bin/sh +#set -e +set -x + if [ $# -ne 2 ]; then echo "cores_backtrace.sh <os> <directory>" exit 1 @@ -8,17 +11,32 @@ fi os=$1 directory=$2 +findargs='' case $os in freebsd|linux|macos) - ;; + ;; + + cygwin) + # XXX Evidently I don't know how to write two arguments here without pathname expansion later, other than eval. + #findargs='-name "*.stackdump"' + for stack in $(find "$directory" -type f -name "*.stackdump") ; do + binary=`basename "$stack" .stackdump` + echo;echo; + echo "dumping ${stack} for ${binary}" + awk '/^0/{print $2}' $stack |addr2line -f -i -e ./src/backend/postgres.exe + #awk '/^0/{print $2}' $stack |addr2line -f -i -e "./src/backend/$binary.exe" + done + exit 0 + ;; + *) echo "unsupported operating system ${os}" exit 1 - ;; + ;; esac first=1 -for corefile in $(find "$directory" -type f) ; do +for corefile in $(find "$directory" -type f $findargs) ; do if [ "$first" -eq 1 ]; then first=0 else @@ -28,6 +46,13 @@ for corefile in $(find "$directory" -type f) ; do if [ "$os" = 'macos' ]; then lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit' + elif [ "$os" = 'cygwin' ]; then + # https://cirrus-ci.com/task/4964259674193920 + #binary=${corefile%.stackdump} + #binary=${corefile#*/} + binary=`basename "$corefile" .stackdump` + echo "dumping ${corefile} for ${binary}" + awk '/^0/{print $2}' $corefile |addr2line -f -i -e ./src/backend/postgres.exe else auxv=$(gdb --quiet --core ${corefile} --batch -ex 'info auxv' 2>/dev/null) if [ $? -ne 0 ]; then @@ -48,3 +73,5 @@ for corefile in $(find "$directory" -type f) ; do gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" "$binary" "$corefile" 2>/dev/null fi done + +exit 0 diff --git a/src/tools/ci/pg_ci_base.conf b/src/tools/ci/pg_ci_base.conf index d8faa9c26c1..206dd993ccc 100644 --- a/src/tools/ci/pg_ci_base.conf +++ b/src/tools/ci/pg_ci_base.conf @@ -12,3 +12,5 @@ log_connections = true log_disconnections = true log_line_prefix = '%m [%p][%b] %q[%a][%v:%x] ' log_lock_waits = true + +data_sync_retry = on -- 2.25.1
>From 9aace45e27a1bc0bacd5922db9878d724b7bc492 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Wed, 28 Sep 2022 19:54:59 -0500 Subject: [PATCH 3/3] f!convert to meson https://cirrus-ci.com/task/5982327657463808 https://community.chocolatey.org/packages/Cygwin#versionhistory ci-os-only: cygwin --- .cirrus.yml | 34 +++++++++++++-------------------- src/tools/ci/cores_backtrace.sh | 4 ++-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 02b0f3b7045..57610e669e8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -466,24 +466,24 @@ task: task: name: Windows - Cygwin - only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*' #XXX only_if: $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*cygwin.*' - timeout_in: 90m + #XXX 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 CCACHE_LOGFILE: ccache.log - CONFIGURE_FLAGS: --enable-cassert --enable-debug --with-ldap --with-ssl=openssl --with-libxml - # --enable-tap-tests # --disable-dynamicbase # --with-gssapi CONFIGURE_CACHE: /tmp/ccache/configure.cache PG_TEST_USE_UNIX_SOCKETS: 1 EXTRA_REGRESS_OPTS: --max-connections=1 PG_TEST_EXTRA: ldap ssl # disable kerberos + CC: ccache gcc + CFLAGS: -Og -ggdb windows_container: image: cirrusci/windowsservercore:2019-2022.06.23 @@ -493,7 +493,7 @@ task: 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 + 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" @@ -514,28 +514,20 @@ task: reupload_on_changes: true 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 -Dssl=openssl -Duuid=e2fs -Dtap_tests=disabled -DPG_TEST_EXTRA='$PG_TEST_EXTRA' build" build_script: - #- C:\tools\cygwin\bin\bash.exe --login -c "ccache --max-size ${CCACHE_MAXSIZE}" - - C:\tools\cygwin\bin\bash.exe --login -c "ccache --zero-stats" - - 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" - upload_caches: ccache + always: + upload_caches: ccache test_world_script: - #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/subscription" - #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/recovery" - - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/test/modules/test_misc" - - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/interfaces/libpq" - - C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s -j ${TEST_JOBS} check ${CHECKFLAGS} -C src/bin/psql" - #- C:\tools\cygwin\bin\bash.exe --login -c "cd '%cd%' && timeout 44m make -s check ${CHECKFLAGS} -C src/bin -j 2" - - 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_ac + <<: *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 02bd50b10fa..1f0f8795fc6 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/postgres.exe - #awk '/^0/{print $2}' $stack |addr2line -f -i -e "./src/backend/$binary.exe" + awk '/^0/{print $2}' $stack |addr2line -f -i -e ./build/tmp_install/usr/local/pgsql/bin/postgres.exe + #awk '/^0/{print $2}' $stack |addr2line -f -i -e "./build/src/backend/$binary.exe" done exit 0 ;; -- 2.25.1