From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: MSYS2 support
Date: Thu, 12 Dec 2019 22:11:36 +0100
Message-ID: <6b467edc-4018-521f-ab18-171f098557ca@2ndquadrant.com> (raw)
There were a number of recent threads about building PostgreSQL on
MSYS2. This has been confusing on occasion; see for example [0]. MSYS2
is actually a derivative of Cygwin. What most people are actually doing
is using MSYS2 has the host environment for doing a kind of
cross-compilation to MinGW.
You can also build natively on MSYS2, using the existing Cygwin support.
Except that it won't work because configure doesn't recognize the
config.guess output. Attached are a couple of small patches to fix that
up. The first patch fixes configure as explained. The second patch
fixes some warnings in ps_status.c. It's curious why the existing build
farm members don't issue warnings there, but maybe their compilers are
too old. The third patch fixes another warning; again, not sure why
original Cygwin doesn't warn. It might be a bit too broad to apply like
that.
MSYS2 doesn't ship with cygserver AFAICT, so you can't run a PostgreSQL
server, but everything else should work.
[0]:
https://www.postgresql.org/message-id/6672cebd-0c07-ce1e-36f8-6ae82c496eb0@2ndquadrant.com
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:download all (3 files, .tar.gz)0001-Add-support-for-MSYS2.patch (text/plain, 2.8K) download
From 676e1392705e017cc5ae17e0f35952f8a1405eab Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sun, 18 Aug 2019 00:17:16 +0200
Subject: [PATCH 1/3] Add support for MSYS2
It's basically a variant of Cygwin, so use that template.
---
configure | 12 +++++-------
configure.in | 12 +++++-------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/configure b/configureindex 3d9bd0bdf8..7f86a7e5ff 100755--- a/configure+++ b/configure@@ -2946,7 +2946,7 @@ else
case $host_os in
aix*) template=aix ;;
- cygwin*) template=cygwin ;;+ cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
freebsd*) template=freebsd ;;
@@ -15843,24 +15843,22 @@ fi-case $host_os in+if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
# have a broken strtof(), so substitute the same replacement
# code we use with VS2013. That's not a perfect fix, since
# (unlike with VS2013) it doesn't avoid double-rounding, but
# we have no better options. To get that, though, we have to
# force the file to be compiled despite HAVE_STRTOF.
- mingw*|cygwin*)- case " $LIBOBJS " in+ case " $LIBOBJS " in
*" strtof.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS strtof.$ac_objext"
;;
esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: On $host_os we will use our strtof wrapper." >&5+ { $as_echo "$as_me:${as_lineno-$LINENO}: On $host_os we will use our strtof wrapper." >&5
$as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
- ;;-esac+fi
case $host_os in
diff --git a/configure.in b/configure.inindex 34aea0b4ac..797a9db01d 100644--- a/configure.in+++ b/configure.in@@ -59,7 +59,7 @@ PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
case $host_os in
aix*) template=aix ;;
- cygwin*) template=cygwin ;;+ cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
freebsd*) template=freebsd ;;
@@ -1743,18 +1743,16 @@ AC_REPLACE_FUNCS(m4_normalize([
strtof
]))
-case $host_os in+if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
# have a broken strtof(), so substitute the same replacement
# code we use with VS2013. That's not a perfect fix, since
# (unlike with VS2013) it doesn't avoid double-rounding, but
# we have no better options. To get that, though, we have to
# force the file to be compiled despite HAVE_STRTOF.
- mingw*|cygwin*)- AC_LIBOBJ([strtof])- AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])- ;;-esac+ AC_LIBOBJ([strtof])+ AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])+fi
case $host_os in
--
2.24.0
0002-Fix-compiler-warnings.patch (text/plain, 1.2K) download
From bf5be8c29babcd86e12d9f3acfb87d391d61e187 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 11 Dec 2019 08:52:50 +0100
Subject: [PATCH 2/3] Fix compiler warnings
The PS_USE_NONE case left a couple of unused variables exposed.
---
src/backend/utils/misc/ps_status.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.cindex 6c851dd498..288d71d4d2 100644--- a/src/backend/utils/misc/ps_status.c+++ b/src/backend/utils/misc/ps_status.c@@ -89,6 +89,8 @@ bool update_process_title = true;
#endif
+#ifndef PS_USE_NONE+
#ifndef PS_USE_CLOBBER_ARGV
/* all but one option need a buffer to write their ps line in */
#define PS_BUFFER_SIZE 256
@@ -104,6 +106,8 @@ static size_t ps_buffer_cur_len; /* nominal strlen(ps_buffer) */
static size_t ps_buffer_fixed_size; /* size of the constant prefix */
+#endif+
/* save the original argv[] location here */
static int save_argc;
static char **save_argv;
@@ -420,7 +424,11 @@ get_ps_display(int *displen)
}
#endif
+#ifdef PS_USE_NONE+ return "";+#else
*displen = (int) (ps_buffer_cur_len - ps_buffer_fixed_size);
return ps_buffer + ps_buffer_fixed_size;
+#endif
}
--
2.24.0
0003-Fix-compiler-warning-for-ppoll-on-MSYS2.patch (text/plain, 718B) download
From c265d26a9c73555860980f36a127049407dcf695 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 11 Dec 2019 08:55:25 +0100
Subject: [PATCH 3/3] Fix compiler warning for ppoll() on MSYS2
Apparently, _GNU_SOURCE is required to get the prototype, so just
define that globally.
---
src/template/cygwin | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/template/cygwin b/src/template/cygwinindex 79a108145f..0a1ab04e3d 100644--- a/src/template/cygwin+++ b/src/template/cygwin@@ -2,6 +2,9 @@
SRCH_LIB="/usr/local/lib"
+# to get ppoll() prototype+CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"+
# Extra CFLAGS for code that will go into a shared library
CFLAGS_SL=""
--
2.24.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com
Subject: Re: MSYS2 support
In-Reply-To: <6b467edc-4018-521f-ab18-171f098557ca@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox