Skip to content

Commit 84c4313

Browse files
committed
Support linking with MinGW-built Perl.
This is necessary for ActivePerl 5.18 onwards and for Strawberry Perl. It is not sufficient for 32-bit builds with newer Visual Studio; these fail with error LINK2026. Back-patch to 9.3 (all supported versions). Reported by Victor Wagner. Discussion: https://postgr.es/m/[email protected]
1 parent 59b71c6 commit 84c4313

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

config/perl.m4

+12-5
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,19 @@ AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
8383
[AC_REQUIRE([PGAC_PATH_PERL])
8484
AC_MSG_CHECKING(for flags to link embedded Perl)
8585
if test "$PORTNAME" = "win32" ; then
86-
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
87-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
86+
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
87+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
88+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
89+
else
90+
perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
91+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
92+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
93+
fi
94+
fi
8895
else
89-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
90-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
91-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
96+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
97+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
98+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
9299
fi
93100
AC_SUBST(perl_embed_ldflags)dnl
94101
if test -z "$perl_embed_ldflags" ; then

configure

+12-5
Original file line numberDiff line numberDiff line change
@@ -7818,12 +7818,19 @@ $as_echo "$perl_embed_ccflags" >&6; }
78187818
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl" >&5
78197819
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
78207820
if test "$PORTNAME" = "win32" ; then
7821-
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7822-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7821+
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7822+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
7823+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7824+
else
7825+
perl_lib=`basename $perl_archlibexp/CORE/libperl[5-9]*.a .a | sed 's/^lib//'`
7826+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
7827+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7828+
fi
7829+
fi
78237830
else
7824-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
7825-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
7826-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
7831+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
7832+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
7833+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
78277834
fi
78287835
if test -z "$perl_embed_ldflags" ; then
78297836
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5

src/pl/plperl/plperl.h

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
#undef vsnprintf
4343
#endif
4444

45+
/*
46+
* ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's
47+
* __inline__. Translate to something MSVC recognizes.
48+
*/
49+
#ifdef _MSC_VER
50+
#define __inline__ inline
51+
#endif
52+
4553

4654
/*
4755
* Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code

src/tools/msvc/Mkvcbuild.pm

+3-2
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,10 @@ sub mkvcbuild
615615
}
616616
}
617617
$plperl->AddReference($postgres);
618-
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\perl*.lib';
618+
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*';
619+
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
619620
my @perl_libs =
620-
grep { /perl\d+.lib$/ } glob($perl_path);
621+
grep { /perl\d+\.lib$|libperl\d+\.a$/ } glob($perl_path);
621622
if (@perl_libs == 1)
622623
{
623624
$plperl->AddLibrary($perl_libs[0]);

0 commit comments

Comments
 (0)