Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c163a7

Browse files
committed
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl shouldbe built with the compiler switches shown by Perl's $Config{ccflags}.We'd been ignoring that up to now, and mostly getting away with it,but recent Perl versions contain ABI compatibility cross-checks thatfail on some builds because of this omission. In particular thesizeof(PerlInterpreter) can come out different due to some fields beingadded or removed; which means we have a live ABI hazard that we'd betterfix rather than continuing to sweep it under the rug.However, it still seems like a bad idea to just absorb $Config{ccflags}verbatim. In some environments Perl was built with a different compilerthat doesn't even use the same switch syntax. -D switch syntax is prettyuniversal though, and absorbing Perl's -D switches really ought to beenough to fix the problem.Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs onplatforms where they're relevant. Adopting those seems dangerous too.It's unclear whether a build wherein Perl and Postgres have different ideasof sizeof(off_t) etc would work, or whether anyone would care about makingit work. But it's dead certain that having different stdio ABIs incore Postgres and PL/Perl will not work; we've seen that movie before.Therefore, let's also ignore -D switches for symbols beginning withunderscore. The symbols that we actually need to import should be the onesmentioned in perl.h's PL_bincompat_options stanza, and none of those startwith underscore, so this seems likely to work. (If it turns out not towork everywhere, we could consider intersecting the symbols mentioned inPL_bincompat_options with the -D switches. But that will be much morecomplicated, so let's try this way first.)This will need to be back-patched, but first let's see what thebuildfarm makes of it.Ashutosh Sharma, some adjustments by meDiscussion:https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
1 parentbebe174 commit3c163a7

File tree

7 files changed

+71
-4
lines changed

7 files changed

+71
-4
lines changed

‎config/perl.m4

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ AC_DEFUN([PGAC_CHECK_PERL_CONFIGS],
4949
[m4_foreach([pgac_item],[$1],[PGAC_CHECK_PERL_CONFIG(pgac_item)])])
5050

5151

52+
# PGAC_CHECK_PERL_EMBED_CCFLAGS
53+
# -----------------------------
54+
# We selectively extract stuff from $Config{ccflags}. We don't really need
55+
# anything except -D switches, and other sorts of compiler switches can
56+
# actively break things if Perl was compiled with a different compiler.
57+
# Moreover, although Perl likes to put stuff like -D_LARGEFILE_SOURCE and
58+
# -D_FILE_OFFSET_BITS=64 here, it would be fatal to try to compile PL/Perl
59+
# to a different libc ABI than core Postgres uses. The available information
60+
# says that all the symbols that affect Perl's own ABI begin with letters,
61+
# so it should be sufficient to adopt -D switches for symbols not beginning
62+
# with underscore.
63+
# For debugging purposes, let's have the configure output report the raw
64+
# ccflags value as well as the set of flags we chose to adopt.
65+
AC_DEFUN([PGAC_CHECK_PERL_EMBED_CCFLAGS],
66+
[AC_REQUIRE([PGAC_PATH_PERL])
67+
AC_MSG_CHECKING([for CFLAGS recommended by Perl])
68+
perl_ccflags=`$PERL -MConfig -e['print $Config{ccflags}']`
69+
AC_MSG_RESULT([$perl_ccflags])
70+
AC_MSG_CHECKING([for CFLAGS to compile embedded Perl])
71+
perl_embed_ccflags=`$PERL -MConfig -e['foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}']`
72+
AC_SUBST(perl_embed_ccflags)dnl
73+
AC_MSG_RESULT([$perl_embed_ccflags])
74+
])# PGAC_CHECK_PERL_EMBED_CCFLAGS
75+
76+
5277
# PGAC_CHECK_PERL_EMBED_LDFLAGS
5378
# -----------------------------
5479
# We are after Embed's ldopts, but without the subset mentioned in

‎configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ python_version
668668
python_majorversion
669669
PYTHON
670670
perl_embed_ldflags
671+
perl_embed_ccflags
671672
perl_useshrplib
672673
perl_privlibexp
673674
perl_archlibexp
@@ -7767,6 +7768,18 @@ documentation for details. Use --without-perl to disable building
77677768
PL/Perl.""$LINENO" 5
77687769
fi
77697770

7771+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for CFLAGS recommended by Perl">&5
7772+
$as_echo_n"checking for CFLAGS recommended by Perl...">&6; }
7773+
perl_ccflags=`$PERL -MConfig -e'print $Config{ccflags}'`
7774+
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$perl_ccflags">&5
7775+
$as_echo"$perl_ccflags">&6; }
7776+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for CFLAGS to compile embedded Perl">&5
7777+
$as_echo_n"checking for CFLAGS to compile embedded Perl...">&6; }
7778+
perl_embed_ccflags=`$PERL -MConfig -e'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}'`
7779+
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$perl_embed_ccflags">&5
7780+
$as_echo"$perl_embed_ccflags">&6; }
7781+
7782+
77707783
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for flags to link embedded Perl">&5
77717784
$as_echo_n"checking for flags to link embedded Perl...">&6; }
77727785
iftest"$PORTNAME" ="win32";then

‎configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ You might have to rebuild your Perl installation. Refer to the
938938
documentation for details. Use --without-perl to disable building
939939
PL/Perl.])
940940
fi
941+
PGAC_CHECK_PERL_EMBED_CCFLAGS
941942
PGAC_CHECK_PERL_EMBED_LDFLAGS
942943
fi
943944

‎contrib/hstore_plperl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ endif
3838
# last, probably because it sometimes contains some header files with names
3939
# that clash with some of ours, or with some that we include, notably on
4040
# Windows.
41-
overrideCPPFLAGS :=$(CPPFLAGS) -I$(perl_archlibexp)/CORE
41+
overrideCPPFLAGS :=$(CPPFLAGS)$(perl_embed_ccflags)-I$(perl_archlibexp)/CORE

‎src/Makefile.global.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ else
304304
endif
305305
perl_archlibexp= @perl_archlibexp@
306306
perl_privlibexp= @perl_privlibexp@
307+
perl_embed_ccflags= @perl_embed_ccflags@
307308
perl_embed_ldflags= @perl_embed_ldflags@
308309

309310
# Miscellaneous

‎src/pl/plperl/GNUmakefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
1212
overrideCPPFLAGS += -Wno-comment
1313
endif
1414

15-
overrideCPPFLAGS := -I. -I$(srcdir)$(CPPFLAGS) -I$(perl_archlibexp)/CORE
15+
# Note: we need to make sure that the CORE directory is included last,
16+
# probably because it sometimes contains some header files with names
17+
# that clash with some of ours, or with some that we include, notably on
18+
# Windows.
19+
overrideCPPFLAGS := -I. -I$(srcdir)$(CPPFLAGS)$(perl_embed_ccflags) -I$(perl_archlibexp)/CORE
1620

1721
rpathdir =$(perl_archlibexp)/CORE
1822

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,26 @@ sub mkvcbuild
517517
my$plperl =
518518
$solution->AddProject('plperl','dll','PLs','src/pl/plperl');
519519
$plperl->AddIncludeDir($solution->{options}->{perl} .'/lib/CORE');
520-
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
520+
521+
# Add defines from Perl's ccflags; see PGAC_CHECK_PERL_EMBED_CCFLAGS
522+
my@perl_embed_ccflags;
523+
foreachmy$f (split("",$Config{ccflags}))
524+
{
525+
if ($f =~/^-D[^_]/)
526+
{
527+
$f =~s/\-D//;
528+
push(@perl_embed_ccflags,$f);
529+
}
530+
}
531+
532+
# XXX this probably is redundant now?
533+
push(@perl_embed_ccflags,'PLPERL_HAVE_UID_GID');
534+
535+
foreachmy$f (@perl_embed_ccflags)
536+
{
537+
$plperl->AddDefine($f);
538+
}
539+
521540
foreachmy$xs ('SPI.xs','Util.xs')
522541
{
523542
(my$xsc =$xs) =~s/\.xs/.c/;
@@ -601,7 +620,11 @@ sub mkvcbuild
601620
'hstore_plperl','contrib/hstore_plperl',
602621
'plperl','src/pl/plperl',
603622
'hstore','contrib/hstore');
604-
$hstore_plperl->AddDefine('PLPERL_HAVE_UID_GID');
623+
624+
foreachmy$f (@perl_embed_ccflags)
625+
{
626+
$hstore_plperl->AddDefine($f);
627+
}
605628
}
606629

607630
$mf =

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp