Building PL/Perl with ActiveState Perl 5.22 and MSVC

From: Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Building PL/Perl with ActiveState Perl 5.22 and MSVC
Date: 2016-03-26 12:43:21
Message-ID: 20160326154321.7754ab8f@wagner.wagner.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Collegues,

Since patches to support building postgres itself with newest version
of ActivePerl was commited into REL9_5_STABLE branch, I've tried to
build postgres with PL/Perl using this version of Perl. I'm using
Visual Studio 2013 Community edition.

It turns out that while ActiveState seems to drop support of embedding
their perl into msvc-compiled appications, there are just few minor
issues which prevent PL-perl to compile.

1. ActiveState Perl doesn't ship MSVC-build import library perl522.lib
for their perl522.dll. Instead they ship MINGW-build library
libperl522.a.

Visual Studio 2012 is able to link against this library. It is only
matter of modifing search expresions in Mkvcbuild.pm to be able to find
this import library. Not sure if it stands true for all eariler
versions of Visual Studio, supported by Postgresql.

2. There is macro PERL_STATIC_INLINME in perl's lib/CORE/config.h file,
which produces compilation errors.

There are following comments there:

/* HAS_STATIC_INLINE:
* This symbol, if defined, indicates that the C compiler supports
* C99-style static inline. That is, the function can't be called
* from another translation unit.
*/
/* PERL_STATIC_INLINE:
* This symbol gives the best-guess incantation to use for static
* inline functions. If HAS_STATIC_INLINE is defined, this will
* give C99-style inline. If HAS_STATIC_INLINE is not defined,
* this will give a plain 'static'. It will always be defined
* to something that gives static linkage.
* Possibilities include
* static inline (c99)
* static __inline__ (gcc -ansi)
* static __inline (MSVC)
* static _inline (older MSVC)
* static (c89 compilers)
*/
#define HAS_STATIC_INLINE /**/
#define PERL_STATIC_INLINE static __inline__ /**/

Changing that macro to one described in the comments as "for MSVC" make
compilation errors to go away. Unfortunately, I have no idea how to
fix this from within postgresql compilation process.

3. Fixing two issues above was enough to make build complete for 64-bit
windows target. With 32-bit build I'v got linking errors
LINK2026: module unsafe for safeseh image

for all modules which are linked with perl DLL. I suspect that it is
not a problem with DLL itself, it is rather related to way MINGW32
generates its import libraries. To fix this problem XML element
<ImageHasSafeExceptionHandlers>false</ImageHasExceptionHandlers>
should be added inside <Link> element of the two vcxproj files which
link with perl - plperl.vcxproj and hstore_plperl.vcxproj.

It seems that this option appeared in VC2003, so it should be safe to
add.

Hope that results of my experiments would be useful for someone.

--
Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-03-26 14:01:40 Re: Can we amend gitignore so git postgresql works with git on windows using Msys/Mingw64
Previous Message Andres Freund 2016-03-26 12:39:42 Re: Breakage with VACUUM ANALYSE + partitions