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

Commit0d8f015

Browse files
committed
PL/Perl portability fix: absorb relevant -D switches from Perl.
Back-patch of commit3c163a7,which see for more info.Also throw in commitb4cc35f,so Coverity doesn't whine about the back branches.Ashutosh Sharma, some adjustments by meDiscussion:https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
1 parentb92f172 commit0d8f015

File tree

7 files changed

+82
-13
lines changed

7 files changed

+82
-13
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
@@ -682,6 +682,7 @@ python_version
682682
python_majorversion
683683
PYTHON
684684
perl_embed_ldflags
685+
perl_embed_ccflags
685686
perl_useshrplib
686687
perl_privlibexp
687688
perl_archlibexp
@@ -7601,6 +7602,18 @@ test "$PORTNAME" = "win32" && perl_useshrplib=`echo $perl_useshrplib | sed 's,\\
76017602
{ $as_echo "$as_me:$LINENO: result: $perl_useshrplib" >&5
76027603
$as_echo "$perl_useshrplib" >&6; }
76037604

7605+
{ $as_echo "$as_me:$LINENO: checking for CFLAGS recommended by Perl" >&5
7606+
$as_echo_n "checking for CFLAGS recommended by Perl... " >&6; }
7607+
perl_ccflags=`$PERL -MConfig -e 'print $Config{ccflags}'`
7608+
{ $as_echo "$as_me:$LINENO: result: $perl_ccflags" >&5
7609+
$as_echo "$perl_ccflags" >&6; }
7610+
{ $as_echo "$as_me:$LINENO: checking for CFLAGS to compile embedded Perl" >&5
7611+
$as_echo_n "checking for CFLAGS to compile embedded Perl... " >&6; }
7612+
perl_embed_ccflags=`$PERL -MConfig -e 'foreach $f (split(" ",$Config{ccflags})) {print $f, " " if ($f =~ /^-D[^_]/)}'`
7613+
{ $as_echo "$as_me:$LINENO: result: $perl_embed_ccflags" >&5
7614+
$as_echo "$perl_embed_ccflags" >&6; }
7615+
7616+
76047617
{ $as_echo "$as_me:$LINENO: checking for flags to link embedded Perl" >&5
76057618
$as_echo_n "checking for flags to link embedded Perl... " >&6; }
76067619
if test "$PORTNAME" = "win32" ; then

‎configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ if test "$with_perl" = yes; then
850850
AC_MSG_ERROR([Perl not found])
851851
fi
852852
PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
853+
PGAC_CHECK_PERL_EMBED_CCFLAGS
853854
PGAC_CHECK_PERL_EMBED_LDFLAGS
854855
fi
855856

‎src/Makefile.global.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ endif
277277
perl_archlibexp= @perl_archlibexp@
278278
perl_privlibexp= @perl_privlibexp@
279279
perl_useshrplib= @perl_useshrplib@
280+
perl_embed_ccflags= @perl_embed_ccflags@
280281
perl_embed_ldflags= @perl_embed_ldflags@
281282

282283
# Miscellaneous

‎src/pl/plperl/GNUmakefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
2222
overrideCFLAGS += -Wno-comment
2323
endif
2424

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

2731
rpathdir =$(perl_archlibexp)/CORE
2832

‎src/pl/plperl/plperl.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,12 +3056,18 @@ plperl_return_next_internal(SV *sv)
30563056

30573057
/*
30583058
* This is the first call to return_next in the current PL/Perl
3059-
* function call, so memoize some lookups
3059+
* function call, so identify the output tuple descriptor and create a
3060+
* tuplestore to hold the result rows.
30603061
*/
30613062
if (prodesc->fn_retistuple)
30623063
(void)get_call_result_type(fcinfo,NULL,&tupdesc);
30633064
else
3065+
{
30643066
tupdesc=rsi->expectedDesc;
3067+
/* Protect assumption below that we return exactly one column */
3068+
if (tupdesc==NULL||tupdesc->natts!=1)
3069+
elog(ERROR,"expected single-column result descriptor for non-composite SETOF result");
3070+
}
30653071

30663072
/*
30673073
* Make sure the tuple_store and ret_tdesc are sufficiently
@@ -3111,20 +3117,20 @@ plperl_return_next_internal(SV *sv)
31113117
}
31123118
else
31133119
{
3114-
Datumret;
3115-
boolisNull;
3120+
Datumret[1];
3121+
boolisNull[1];
31163122

3117-
ret=plperl_sv_to_datum(sv,
3118-
prodesc->result_oid,
3119-
-1,
3120-
fcinfo,
3121-
&prodesc->result_in_func,
3122-
prodesc->result_typioparam,
3123-
&isNull);
3123+
ret[0]=plperl_sv_to_datum(sv,
3124+
prodesc->result_oid,
3125+
-1,
3126+
fcinfo,
3127+
&prodesc->result_in_func,
3128+
prodesc->result_typioparam,
3129+
&isNull[0]);
31243130

31253131
tuplestore_putvalues(current_call_data->tuple_store,
31263132
current_call_data->ret_tdesc,
3127-
&ret,&isNull);
3133+
ret,isNull);
31283134
}
31293135

31303136
MemoryContextSwitchTo(old_cxt);

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,26 @@ sub mkvcbuild
140140
my$plperl =
141141
$solution->AddProject('plperl','dll','PLs','src\pl\plperl');
142142
$plperl->AddIncludeDir($solution->{options}->{perl} .'/lib/CORE');
143-
$plperl->AddDefine('PLPERL_HAVE_UID_GID');
143+
144+
# Add defines from Perl's ccflags; see PGAC_CHECK_PERL_EMBED_CCFLAGS
145+
my@perl_embed_ccflags;
146+
foreachmy$f (split("",$Config{ccflags}))
147+
{
148+
if ($f =~/^-D[^_]/)
149+
{
150+
$f =~s/\-D//;
151+
push(@perl_embed_ccflags,$f);
152+
}
153+
}
154+
155+
# XXX this probably is redundant now?
156+
push(@perl_embed_ccflags,'PLPERL_HAVE_UID_GID');
157+
158+
foreachmy$f (@perl_embed_ccflags)
159+
{
160+
$plperl->AddDefine($f);
161+
}
162+
144163
foreachmy$xs ('SPI.xs','Util.xs')
145164
{
146165
(my$xsc =$xs) =~s/\.xs/.c/;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp