From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Strip -mmacosx-version-min options from plperl build
Date: Fri, 19 Aug 2022 09:12:06 +0200
Message-ID: <9518842c-6844-0c99-85ec-ec43fba3115f@enterprisedb.com> (raw)
In-Reply-To: <2369869.1660830828@sss.pgh.pa.us>
References: <8c4fcb72-2574-ff7c-4c25-1f032d4a2a57@enterprisedb.com>
<2369869.1660830828@sss.pgh.pa.us>
On 18.08.22 15:53, Tom Lane wrote:
> Agreed on rejecting -mmacosx-version-min, but I wonder if we should
> think about adopting a whitelist-instead-of-blacklist approach to
> adopting stuff from perl_embed_ldflags. ISTR that in pltcl we already
> use the approach of accepting only -L and -l, and perhaps similar
> strictness would serve us well here.
>
> As an example, on a not-too-new MacPorts install, I see
>
> $ /opt/local/bin/perl -MExtUtils::Embed -e ldopts
> -L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector-strong -L/opt/local/lib/perl5/5.28/darwin-thread-multi-2level/CORE -lperl
>
> I can't see any really good reason why we should allow perl
> to be injecting that sort of -f option into the plperl build,
> and I'm pretty dubious about the -headerpad_max_install_names
> bit too.
>
> I think also that this would allow us to drop the weird dance of
> trying to subtract ccdlflags.
After analyzing the source code of ExtUtils::Embed's ldopts, I think we
can also do this by subtracting $Config{ldflags}, since
my $linkage = "$ccdlflags $ldflags @archives $ld_or_bs";
and we really just want the $ld_or_bs part. (@archives should be empty
for our uses.)
This would get rid of -mmacosx-version-min and -arch and all the things
you showed, including -L/opt/local/lib, which is probably there so that
the build of Perl itself could look there for things, but we don't need it.
Attachments:v2-0001-Remove-further-unwanted-linker-flags-from-perl_em.patch (text/plain, 2.9K) download
From 58e429d7c5a0b7f9dd720ee948d90c7d45de4638 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 19 Aug 2022 08:07:23 +0200
Subject: [PATCH v2] Remove further unwanted linker flags from
perl_embed_ldflags
Remove the contents of $Config{ldflags} from ExtUtils::Embed's ldopts,
like we already do with $Config{ccdlflags}. Those flags the choices
of those who built the Perl installation, which are not necessarily
appropriate for building PostgreSQL. What we really want from ldopts
are the options identifying the location and name of the libperl
library, but unfortunately it doesn't appear possible to get that
separately from the other stuff.
The motivation for this was to strip -mmacosx-version-min options. We
already did something similar for the -arch option. Both of those are
now covered by this more general approach.
---
config/perl.m4 | 10 +++++-----
configure | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/config/perl.m4 b/config/perl.m4index c823fc8cf0..c9fd91397c 100644--- a/config/perl.m4+++ b/config/perl.m4@@ -81,9 +81,9 @@ AC_MSG_RESULT([$perl_embed_ccflags])
# PGAC_CHECK_PERL_EMBED_LDFLAGS
# -----------------------------
# We are after Embed's ldopts, but without the subset mentioned in
-# Config's ccdlflags; and also without any -arch flags, which recent-# Apple releases put in unhelpfully. (If you want a multiarch build-# you'd better be specifying it in more places than plperl's final link.)+# Config's ccdlflags and ldflags. (Those are the choices of those who+# built the Perl installation, which are not necessarily appropriate+# for building PostgreSQL.)
AC_DEFUN([PGAC_CHECK_PERL_EMBED_LDFLAGS],
[AC_REQUIRE([PGAC_PATH_PERL])
AC_MSG_CHECKING(for flags to link embedded Perl)
@@ -99,8 +99,8 @@ if test "$PORTNAME" = "win32" ; then
fi
else
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
- pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`- perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`+ pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`+ perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
fi
AC_SUBST(perl_embed_ldflags)dnl
if test -z "$perl_embed_ldflags" ; then
diff --git a/configure b/configureindex 176e0f9b00..d9b461ed91 100755--- a/configure+++ b/configure@@ -10478,8 +10478,8 @@ if test "$PORTNAME" = "win32" ; then
fi
else
pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
- pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`- perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`+ pgac_tmp2=`$PERL -MConfig -e 'print "$Config{ccdlflags} $Config{ldflags}"'`+ perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%"`
fi
if test -z "$perl_embed_ldflags" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--
2.37.1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@enterprisedb.com, tgl@sss.pgh.pa.us
Subject: Re: Strip -mmacosx-version-min options from plperl build
In-Reply-To: <9518842c-6844-0c99-85ec-ec43fba3115f@enterprisedb.com>
References: <8c4fcb72-2574-ff7c-4c25-1f032d4a2a57@enterprisedb.com> <2369869.1660830828@sss.pgh.pa.us> <9518842c-6844-0c99-85ec-ec43fba3115f@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox