10000 Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant. · lelisa2016/postgres@e3335ec · GitHub
[go: up one dir, main page]

Skip to content

Commit e3335ec

Browse files
committed
Absorb -D_USE_32BIT_TIME_T switch from Perl, if relevant.
Commit 3c163a7's original choice to ignore all #define symbols whose names begin with underscore turns out to be too simplistic. On Windows, some Perl installations are built with -D_USE_32BIT_TIME_T, and we must absorb that or we get the wrong result for sizeof(PerlInterpreter). This effectively re-reverts commit ef58b87, which injected that symbol in a hacky way, making it apply to all of Postgres not just PL/Perl. More significantly, it did so on *all* 32-bit Windows builds, even when the Perl build to be used did not select this option; so that it fails to work properly with some newer Perl builds. By making this change, we would be introducing an ABI break in 32-bit Windows builds; but fortunately we have not used type time_t in any exported Postgres APIs in a long time. So it should be OK, both for PL/Perl itself and for third-party extensions, if an extension library is built with a different _USE_32BIT_TIME_T setting than the core code. Patch by me, based on research by Ashutosh Sharma and Robert Haas. Back-patch to all supported branches, as commit 3c163a7 was. Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
1 parent 5069017 commit e3335ec

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

config/perl.m4

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
5858
# to a different libc ABI than core Postgres uses. The available information
5959
# says that all the symbols that affect Perl's own ABI begin with letters,
6060
# so it should be sufficient to adopt -D switches for symbols not beginning
61-
# with underscore.
61+
# with underscore. An exception is that we need to let through
62+
# -D_USE_32BIT_TIME_T if it's present. (We probably could restrict that to
63+
# only get through on Windows, but for the moment we let it through always.)
6264
# For debugging purposes, let's have the configure output report the raw
6365
# ccflags value as well as the set of flags we chose to adopt.
6466
AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
@@ -67,7 +69,7 @@ AC_MSG_CHECKING([for CFLAGS recommended by Perl])
6769
perl_ccflags=`$PERL -MConfig -e ['print $Config{ccflags}']`
6870
AC_MSG_RESULT([$perl_ccflags])
6971
AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
70-
perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}']`
72+
perl_embed_ccflags=`$PERL -MConfig -e ['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}']`
7173
AC_SUBST(perl_embed_ccflags)dnl
7274
AC_MSG_RESULT([$perl_embed_ccflags])
7375
])# PGAC_CHECK_PERL_EMBED_CCFLAGS

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7326,7 +7326,7 @@ perl_ccflags=`$PERL -MConfig -e 'print $Config{ccflags}'`
73267326
$as_echo "$perl_ccflags" >&6; }
73277327
{ $as_echo "$as_me:$LINENO: checking for CFLAGS to compile embedded Perl" >&5
73287328
$as_echo_n "checking for CFLAGS to compile embedded Perl... " >&6; }
7329-
perl_embed_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}'`
7329+
perl_embed_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/ || $f =~ /^-D_USE_32BIT_TIME_T/)}'`
73307330
{ $as_echo "$as_me:$LINENO: result: $perl_embed_ccflags" >&5
73317331
$as_echo "$perl_embed_ccflags" >&6; }
73327332

src/tools/msvc/MSBuildProject.pm

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,16 @@ EOF
6262
</PropertyGroup>
6363
EOF
6464

65-
# We have to use this flag on 32 bit targets because the 32bit perls
66-
# are built with it and sometimes crash if we don't.
67-
my $use_32bit_time_t =
68-
$self->{platform} eq 'Win32' ? '_USE_32BIT_TIME_T;' : '';
69-
7065
$self->WriteItemDefinitionGroup(
7166
$f, 'Debug',
72-
{ defs => "_DEBUG;DEBUG=1;$use_32bit_time_t",
67+
{ defs => "_DEBUG;DEBUG=1",
7368
opt => 'Disabled',
7469
strpool => 'false',
7570
runtime => 'MultiThreadedDebugDLL' });
7671
$self->WriteItemDefinitionGroup(
7772
$f,
7873
'Release',
79-
{ defs => "$use_32bit_time_t",
74+
{ defs => "",
8075
opt => 'Full',
8176
strpool => 'true',
8277
runtime => 'MultiThreadedDLL' });

src/tools/msvc/Mkvcbuild.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,15 @@ sub mkvcbuild
121121
my @perl_embed_ccflags;
122122
foreach my $f (split(" ",$Config{ccflags}))
123123
{
124-
if ($f =~ /^-D[^_]/)
124+
if ($f =~ /^-D[^_]/ ||
125+
$f =~ /^-D_USE_32BIT_TIME_T/)
125126
{
126127
$f =~ s/\-D//;
127128
push(@perl_embed_ccflags, $f);
128129
}
129130
}
130131

131-
# XXX this probably is redundant now?
132+
# Also, a hack to prevent duplicate definitions of uid_t/gid_t
132133
push(@perl_embed_ccflags, 'PLPERL_HAVE_UID_GID');
133134

134135
foreach my $f (@perl_embed_ccflags)

src/tools/msvc/VCBuildProject.pm

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,17 @@ sub WriteHeader
3333
<Configurations>
3434
EOF
3535

36-
# We have to use this flag on 32 bit targets because the 32bit perls
37-
# are built with it and sometimes crash if we don't.
38-
my $use_32bit_time_t =
39-
$self->{platform} eq 'Win32' ? '_USE_32BIT_TIME_T;' : '';
40-
41-
4236
$self->WriteConfiguration(
4337
$f, 'Debug',
44-
{ defs => "_DEBUG;DEBUG=1;$use_32bit_time_t",
38+
{ defs => "_DEBUG;DEBUG=1",
4539
wholeopt => 0,
4640
opt => 0,
4741
strpool 57AE => 'false',
4842
runtime => 3 });
4943
$self->WriteConfiguration(
5044
$f,
5145
'Release',
52-
{ defs => "$use_32bit_time_t",
46+
{ defs => "",
5347
wholeopt => 0,
5448
opt => 3,
5549
strpool => 'true',

0 commit comments

Comments
 (0)
0