Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 76f2a0e

Browse files
committed
Improve meson's detection of perl build flags
The current method of detecting perl build flags breaks if the path to perl contains a space. This change makes two improvements. First, instead of getting a list of ldflags and ccdlflags and then trying to filter those out of the reported ldopts, we tell perl to suppress reporting those in the first instance. Second, it tells perl to parse those and output them, one per line. Thus any space on the option in a file name, for example, is preserved. Issue reported off-list by Muralikrishna Bandaru Discussion: https://postgr.es/01117f88-f465-bf6c-9362-083bd72ca305@dunslane.net Backpatch to release 16.
1 parent bc46104 commit 76f2a0e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

meson.build

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,20 +1072,19 @@ if not perlopt.disabled()
10721072
# Config's ccdlflags and ldflags. (Those are the choices of those who
10731073
# built the Perl installation, which are not necessarily appropriate
10741074
# for building PostgreSQL.)
1075-
ldopts = run_command(perl, '-MExtUtils::Embed', '-e', 'ldopts', check: true).stdout().strip()
1076-
undesired = run_command(perl_conf_cmd, 'ccdlflags', check: true).stdout().split()
1077-
undesired += run_command(perl_conf_cmd, 'ldflags', check: true).stdout().split()
1078-
1079-
perl_ldopts = []
1080-
foreach ldopt : ldopts.split(' ')
1081-
if ldopt == '' or ldopt in undesired
1082-
continue
1083-
endif
1084-
1085-
perl_ldopts += ldopt.strip('"')
1086-
endforeach
1075+
perl_ldopts = run_command(perl, '-e', '''
1076+
use ExtUtils::Embed;
1077+
use Text::ParseWords;
1078+
# tell perl to suppress including these in ldopts
1079+
*ExtUtils::Embed::_ldflags =*ExtUtils::Embed::_ccdlflags = sub { return ""; };
1080+
# adding an argument to ldopts makes it return a value instead of printing
1081+
# print one of these per line so splitting will preserve spaces in file names.
1082+
# shellwords eats backslashes, so we need to escape them.
1083+
(my $opts = ldopts(undef)) =~ s!\\!\\\\!g;
1084+
print "$_\n" foreach shellwords($opts);
1085+
''',
1086+
check: true).stdout().strip().split('\n')
10871087

1088-
message('LDFLAGS recommended by perl: "@0@"'.format(ldopts))
10891088
message('LDFLAGS for embedding perl: "@0@"'.format(' '.join(perl_ldopts)))
10901089

10911090
perl_dep_int = declare_dependency(

0 commit comments

Comments
 (0)