Skip to content

Commit 83e6b14

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/20160326154321.7754ab8f@wagner.wagner.home
1 parent aa3a78c commit 83e6b14

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

config/perl.m4

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,19 @@ AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
8686
[AC_REQUIRE([PGAC_PATH_PERL])
8787
AC_MSG_CHECKING(for flags to link embedded Perl)
8888
if test "$PORTNAME" = "win32" ; then
89-
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
90-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
89+
perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
90+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
91+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
92+
else
93+
perl_lib=`basename $perl_archlibexp/CORE/libperl[[5-9]]*.a .a | sed 's/^lib//'`
94+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
95+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
96+
fi
97+
fi
9198
else
92-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
93-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
94-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
99+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
100+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
101+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
95102
fi
96103
AC_SUBST(perl_embed_ldflags)dnl
97104
if test -z "$perl_embed_ldflags" ; then

configure

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7617,12 +7617,19 @@ $as_echo "$perl_embed_ccflags" >&6; }
76177617
{ $as_echo "$as_me:$LINENO: checking for flags to link embedded Perl" >&5
76187618
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
76197619
if test "$PORTNAME" = "win32" ; then
7620-
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7621-
test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7620+
perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
7621+
if test -e "$perl_archlibexp/CORE/$perl_lib.lib"; then
7622+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7623+
else
7624+
perl_lib=`basename $perl_archlibexp/CORE/libperl[5-9]*.a .a | sed 's/^lib//'`
7625+
if test -e "$perl_archlibexp/CORE/lib$perl_lib.a"; then
7626+
perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
7627+
fi
7628+
fi
76227629
else
7623-
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
7624-
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
7625-
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
7630+
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
7631+
pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
7632+
perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
76267633
fi
76277634
if test -z "$perl_embed_ldflags" ; then
76287635
{ $as_echo "$as_me:$LINENO: result: no" >&5

src/pl/plperl/plperl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
#undef vsnprintf
4545
#endif
4646

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

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

src/tools/msvc/Mkvcbuild.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ sub mkvcbuild
238238
}
239239
}
240240
$plperl->AddReference($postgres);
241+
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*';
242+
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
241243
my @perl_libs =
242-
grep { /perl\d+.lib$/ }
243-
glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib');
244+
grep { /perl\d+\.lib$|libperl\d+\.a$/ } glob($perl_path);
244245
if (@perl_libs == 1)
245246
{
246247
$plperl->AddLibrary($perl_libs[0]);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy