Re: pl/perl extension fails on Windows
Ashutosh Sharma <ashu.coek88@gmail.com>
From: Ashutosh Sharma <ashu.coek88@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>, Dave Page <dpage@pgadmin.org>,
Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-07-28T16:16:41Z
Lists: pgsql-hackers
Attachments
- plperl_win_v3.patch (text/x-patch) patch v3
- plperl_linux_v2.patch (text/x-patch) patch v2
On Fri, Jul 28, 2017 at 7:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ashutosh Sharma <ashu.coek88@gmail.com> writes:
>> Thanks for the patch. I am seeing some compilation errors on Windows
>> with the patch. Below are the errors observed,
>> ...
>> I did spent some time to find reason for these compilation errors and
>> could eventually find that some of the Windows specific functions
>> inside plperl module are calling Perl APIs without fetching the perl
>> interpreter's context using dTHX.
>
> Ah, thanks. I just stuck that in where compiler errors were telling
> me to, so I didn't realize there were Windows-specific functions to
> worry about.
>
>> Moreover, I have also tested this patch along with the patch to import
>> switches used by perl into plperl and together it fixes the server
>> crash issue. Also, now, the interpreter size in both perl and plperl
>> module are the same thereby generating the same key on both plperl and
>> perl module. Thanks.
>
> Excellent. So this looks like the avenue to pursue.
>
> As far as the question of which symbols to import goes: on my own
> machines I'm seeing a lot of things like
>
> $ perl -MConfig -e 'print $Config{ccflags}'
> -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
>
> $ perl -MConfig -e 'print $Config{ccflags}'
> -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DDEBUGGING -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
>
> I'm really quite afraid to import symbols like _LARGEFILE_SOURCE and
> _FILE_OFFSET_BITS into plperl; those *will* break things if they
> are different from what core Postgres is built with. Moreover,
> I came across a relevant data structure in perl.h:
>
> /* These are all the compile time options that affect binary compatibility.
> Other compile time options that are binary compatible are in perl.c
> Both are combined for the output of perl -V
> However, this string will be embedded in any shared perl library, which will
> allow us add a comparison check in perlmain.c in the near future. */
> #ifdef DOINIT
> EXTCONST char PL_bincompat_options[] =
> # ifdef DEBUG_LEAKING_SCALARS
> " DEBUG_LEAKING_SCALARS"
> # endif
> # ifdef DEBUG_LEAKING_SCALARS_FORK_DUMP
> " DEBUG_LEAKING_SCALARS_FORK_DUMP"
> # endif
> # ifdef FAKE_THREADS
> " FAKE_THREADS"
> # endif
> # ifdef MULTIPLICITY
> " MULTIPLICITY"
> # endif
> ... lots more ...
Thanks for sharing this information. I too had a look into
'PL_bincompat_options' data structure in perl.h and i didn't see any
macro name starting with underscore. Based on this information, we can
now confidently say that we do not need any -D switches starting with
underscore for binary compatibility purpose.
>
> Assuming that the Perl crew know what they're doing and this list is
> complete, I notice that not one of the symbols they show as relevant
> starts with an underscore. So I'm thinking that my previous semi-
> joking idea of absorbing only -D switches for names that *don't*
> start with an underscore was actually a good solution.
Yes, it was a good solution indeed.
If that
> turns out to not be enough of a filter, we could consider looking
> into perl.h to extract the set of symbols tested in building
> PL_bincompat_options and then intersecting that with what we get
> from Perl's ccflags. But that would be a lot more complex, so
> I'd rather go with the simpler filter rule for now.
Okay, as per your suggestion, I have modified my earlier patches that
imports the -D switches used by perl into plperl accordingly i.e. it
now ignores the switches whose name starts with underscore. Please
find plperl_win_v3 and plperl_linux_v2 patches attached with this
email.
>
> (BTW, you never did tell us exactly what defines you're getting
> out of Perl's flags on the problem installation.)
I am really sorry about that. I just missed that in my earlier email.
Here are the defines used in the perl where i could reproduce the
issue,
C:\Users\ashu>perl -MConfig -e "print $Config{ccflags}"
-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -fp:precise -DWIN32
-D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DUSE_SITECUSTOMIZE
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
Commits
-
MSVC: Test whether 32-bit Perl needs -D_USE_32BIT_TIME_T.
- 1886899420ce 9.3.21 landed
- aed8d41af628 9.4.16 landed
- 1c1a572d055f 9.5.11 landed
- 140fa2fbad94 9.6.7 landed
- 9b5c99790e83 10.2 landed
- 65a00f30352a 11.0 landed
-
Further tweaks to compiler flags for PL/Perl on Windows.
- f7e4783ddbef 9.2.23 landed
- bc4404405f21 9.3.19 landed
- 4f862351d20b 9.4.14 landed
- bff216d8789f 9.5.9 landed
- c343314882f1 9.6.5 landed
- 1d7a479d22f6 10.0 landed
- b5178c5d08ca 11.0 landed
-
Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant.
- e3335ec0b6a6 9.2.23 landed
- 5a5c2feca3fd 10.0 landed
- 3883be3eae97 9.6.5 landed
- 25169b948e13 9.3.19 landed
- 1621a75531c8 9.5.9 landed
- 01de7ea85378 9.4.14 landed
-
PL/Perl portability fix: absorb relevant -D switches from Perl.
- df52739ce3e7 9.5.8 landed
- 9cbdc689418b 9.4.13 landed
- 456c7dff2af1 9.2.22 landed
- 1e58c503ec46 9.6.4 landed
- 0d8f015e7726 9.3.18 landed
- 3c163a7fc76d 10.0 landed
-
PL/Perl portability fix: avoid including XSUB.h in plperl.c.
- d48180ec812d 9.4.13 landed
- b92f17277eb9 9.3.18 landed
- b4b958251fbf 9.2.22 landed
- 99eea89dbe31 9.5.8 landed
- 30a5c8bfbd7b 9.6.4 landed
- bebe174bb446 10.0 landed