Issues with MinGW W64

From: "Johann 'Myrkraverk' Oskarsson" <johann(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Issues with MinGW W64
Date: 2012-05-29 13:04:32
Message-ID: ovpbg9.x5ovpbg9.pq9n.w333.gnus@asuka.myrkraverk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I am using MingW W64 from SVN, version 3.0 beta-ish.

There are few issues when compiling Postgres with MingW W64. There was
a patch submitted to this list in July 2011 but it does not address
these issues (that I can tell). The following applies to both 32 and 64
bit builds.

----

The header file crtdefs.h in MinGW typedefs errcode which conflicts with
Postgres' elog.h.

#ifndef __ERRCODE_DEFINED_MS
#define __ERRCODE_DEFINED_MS
typedef int errcode;
#endif

The previous patch #undef'ed errcode, which is probably not going to
help here. I added CPPFLAGS=-D__ERRCODE_DEFINED_MS to the configure
line to work around this.

How would a proper patch deal with this? Add an explicit #define when
MinGW W64 is detected?

----

MinGW W64's sys/stat.h #defines stat to be _stati64 and there is
subsequently a compilation error in port.h:

note: expected 'struct _stati64 *' but argument is of type 'struct stat *'
error: conflicting types for 'pgwin32_safestat'

As stupid as it is, I added #undef stat immediately after including
sys/stat.h in port.h:

#if defined(WIN32) && !defined(__CYGWIN__) && !defined(UNSAFE_STAT_OK)
#include <sys/stat.h>
#undef stat
extern int pgwin32_safestat(const char *path, struct stat * buf);

#define stat(a,b) pgwin32_safestat(a,b)
#endif

Though I might have tried -DUNSAFE_STAT_OK too, but didn't.

NOTE: I'm compiling Postgres exclusively to cross compile PL/Java and
run time behaviour is not a concern of mine.

I am not sure what macro magic would be proper here. Comments welcome.

----

There are series of redefined macros from the MinGW W64 CRT.

In pg_config_os:

warning: "_WIN32_WINNT" redefined [enabled by default]
warning: "fseeko" redefined [enabled by default]
warning: "ftello" redefined [enabled by default]
warning: "EMSGSIZE" redefined [enabled by default]
warning: "EAFNOSUPPORT" redefined [enabled by default]
warning: "EWOULDBLOCK" redefined [enabled by default]
warning: "ECONNRESET" redefined [enabled by default]
warning: "EINPROGRESS" redefined [enabled by default]
warning: "ENOBUFS" redefined [enabled by default]
warning: "EPROTONOSUPPORT" redefined [enabled by default]
warning: "ECONNREFUSED" redefined [enabled by default]
warning: "EOPNOTSUPP" redefined [enabled by default]

In port.h:

warning: "popen" redefined [enabled by default]
warning: "pclose" redefined [enabled by default]

And possibly some more. Do we need these redefines?

----

I'm willing to work on some (if not all) of these issues with proper
guidance.

--
Johann Oskarsson http://www.2ndquadrant.com/ |[]
PostgreSQL Development, 24x7 Support, Training and Services --+--
|
Blog: http://my.opera.com/myrkraverk/blog/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2012-05-29 13:12:38 Re: [RFC] Interface of Row Level Security
Previous Message Florian Pflug 2012-05-29 12:58:21 Re: [RFC] Interface of Row Level Security