diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2024-09-14 10:26:25 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2024-09-14 10:37:02 -0400 |
commit | cb52d1cdd1031d3b0d66a001b7b153990a0497c8 (patch) | |
tree | 48cd45a1f453a345fc0c4493862172dfe6c5c891 | |
parent | 0a0db46313749bb379db65eb987af6bf29470300 (diff) | |
download | postgresql-cb52d1cdd1031d3b0d66a001b7b153990a0497c8.tar.gz postgresql-cb52d1cdd1031d3b0d66a001b7b153990a0497c8.zip |
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.
-rw-r--r-- | meson.build | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/meson.build b/meson.build index 54451abe195..e51e1795ae3 100644 --- a/meson.build +++ b/meson.build @@ -1074,20 +1074,19 @@ if not perlopt.disabled() # Config's ccdlflags and ldflags. (Those are the choices of those who # built the Perl installation, which are not necessarily appropriate # for building PostgreSQL.) - ldopts = run_command(perl, '-MExtUtils::Embed', '-e', 'ldopts', check: true).stdout().strip() - undesired = run_command(perl_conf_cmd, 'ccdlflags', check: true).stdout().split() - undesired += run_command(perl_conf_cmd, 'ldflags', check: true).stdout().split() - - perl_ldopts = [] - foreach ldopt : ldopts.split(' ') - if ldopt == '' or ldopt in undesired - continue - endif - - perl_ldopts += ldopt.strip('"') - endforeach + perl_ldopts = run_command(perl, '-e', ''' +use ExtUtils::Embed; +use Text::ParseWords; +# tell perl to suppress including these in ldopts +*ExtUtils::Embed::_ldflags =*ExtUtils::Embed::_ccdlflags = sub { return ""; }; +# adding an argument to ldopts makes it return a value instead of printing +# print one of these per line so splitting will preserve spaces in file names. +# shellwords eats backslashes, so we need to escape them. +(my $opts = ldopts(undef)) =~ s!\\!\\\\!g; +print "$_\n" foreach shellwords($opts); +''', + check: true).stdout().strip().split('\n') - message('LDFLAGS recommended by perl: "@0@"'.format(ldopts)) message('LDFLAGS for embedding perl: "@0@"'.format(' '.join(perl_ldopts))) perl_dep_int = declare_dependency( |