Re: Porting PG Extension from UNIX to Windows

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: "insaf(dot)k" <insaf(dot)k(at)zohocorp(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Porting PG Extension from UNIX to Windows
Date: 2018-04-25 12:09:02
Message-ID: 7e78d3ea-6ba3-c740-6ebc-1d8f23a39fc9@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/25/2018 04:45 AM, insaf.k wrote:
> Hello,
>
> I have developed a postgres extension in Linux. I want to compile it
> in MS Windows as well. 
>
> The extension extensively make use of POSIX threads and mutexes.
>
> I've done some research regarding compiling in Windows. I am not sure
> in what way I should compile the extension. AFAIK, Visual Studio is
> not POSIX compliant and so I'll have to rewrite all those POSIX calls
> using Windows API. So it's better to compile the extension in Cygwin.
>
> I have some questions regarding compiling the extension in Cygwin. Do
> I have to build PG in Cygwin, if I want to compile the extension in
> Cygwin?
>
> Our deployment pattern is like this, build everything in one machine
> and copy the DLLs into the production machine. So, if I compile in
> Cygwin, will the generated DLLs work in other Windows machines? Would
> the target machine be required to install any dependencies related to
> Cygwin in order to use the DLLs?
>
> Also, one more question, not related to PG. Cygwin vs native Windows
> API calls, will there be much difference in the performance?(We are
> not using fork() calls, btw).
>
>
>
>

Performance of postgres under Cygwin is significantly worse than under
native Windows. Unless you're already using Cygwin my advice would be to
stay away from it.

You would probably be better off building with Mingw/Msys (see our docs
for details). It's also possible to use Cmake for extensions, although
this is currently not well documented.

w.r.t. threads and mutexes, you would probably be better off using the
Windows API.  See for example what is said here regarding windows
threads vs posix threads: <https://wiki.qt.io/MinGW-64-bit>

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2018-04-25 12:26:05 Re: [HACKERS] Clock with Adaptive Replacement
Previous Message Andrew Dunstan 2018-04-25 11:54:31 Re: unused_oids script is broken with bsd sed