Re: meson: pass OpenSSL/ICU include dirs to extensions

From: Aidar Imamov <imamovaj22(at)gmail(dot)com>
To: Grigorev Jurij <ju(dot)grigorev(at)ftdata(dot)ru>
Cc: Harrison Booth <harrisontbooth(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: meson: pass OpenSSL/ICU include dirs to extensions
Date: 2026-11-25 16:43:54
Message-ID: FBA2B7FA-BDF8-48DB-9F80-247B5061535C@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On Nov 6, 2026, at 06:27, Grigorev Jurij <ju(dot)grigorev(at)ftdata(dot)ru> wrote:
>
> Hi Aidar,
>
> Thanks for the updates! I reviewed v6 and tested it on Linux aarch64.
> With Meson 1.3.2, an installed PGXS extension gets the OpenSSL and ICU
> flags from non-default prefixes, builds, and loads successfully. I also
> checked the CMake path, including an OpenSSL include directory with a
> space.
>
> I found two remaining issues with Meson 0.57.2:
>
> 1. pkg_config_libdir can be a string, but this line fails in that case:
>
> pkg_config_libdir = [] + meson.get_external_property('pkg_config_libdir', [])
>
> With [properties] pkg_config_libdir = '/usr/lib/aarch64-linux-gnu/pkgconfig',
> setup fails with "can only concatenate list (not \"str\") to list".
> The same configuration succeeds without v6. Could this use an empty
> list followed by +=, as incdirs_list already does?
>
> 2. In 0.57.2 the machine-file binary entry is named 'pkgconfig'. With
> [binaries] pkgconfig pointing to a wrapper, dependency() uses that
> wrapper, but find_program('pkg-config') finds /usr/bin/pkg-config.
> My wrapper selects .pc files with non-default include paths; Meson's
> dependency flags contain those paths, but the exported CPPFLAGS and
> ICU_CFLAGS lose them. Looking up both names fixes this in my test.
>
> I checked both changes together on 0.57.2: the string case configures,
> and the wrapper case exports the expected include paths.
>
> Also, you were right about keeping the host-side lookup: my earlier
> "native: true" suggestion was wrong for cross builds.
>
> Best regards,
> Yuriy

Hi Yuriy,

Thank’s, both of those are real. Reproduced on 0.57.2 and fixed in v7.

The libdir one is mine: get_external_property() returns the property
as-is, Meson itself listifies it in Properties.get_pkg_config_libdir(),
and I did [] + <string>, which 0.57.2 rejects. Newer Meson allows
list + scalar, hence 0.57.2 only. Changed to

pkg_config_libdir = []
pkg_config_libdir += meson.get_external_property('pkg_config_libdir', [])

so a string becomes a one-element list. To check that the value actually
reaches PKG_CONFIG_LIBDIR and not just that the error went away, I used a
private libdir with a libssl.pc carrying an extra -I in Cflags. With the
string form that path shows up in the exported CPPFLAGS, and since
PKG_CONFIG_LIBDIR replaces the whole search path it can only come from
our own pkg-config run.

The pkgconfig one is more interesting. In 0.57.2 the lookup is
find_external_program(env, for_machine, 'pkgconfig', 'Pkg-config',
env.default_pkgconfig, ...), where the second string is just the log
label and default_pkgconfig is ['pkg-config']. So 'pkgconfig' is the
machine-file key, and find_program('pkg-config') looks for a different
entry, doesn't find one, and falls through to PATH. Newer Meson renamed
the entry to 'pkg-config' and aliases the old spelling, so on 1.3.2 it
already does the right thing. find_program('pkgconfig', 'pkg-config')
fixes 0.57.2, and the order matters: with 'pkg-config' first it finds the
PATH binary and never looks at the machine file.

Verified with a wrapper that prepends -I to --cflags. On v6 Meson's
compile commands had that path and the exported flags didn't; on v7 both
do, on 0.57.2 and 1.7.0. Without a machine file the output is unchanged.

One corner: on a new Meson, if the wrapper is under the new 'pkg-config'
key and some 'pkgconfig' happens to be on PATH, we'd take the PATH one.
Reading the machine file from meson.build isn't possible, so I left it.

Tested here on x86_64 macOS: 0.57.2 and 1.7.0, string libdir, list
libdir, wrapper, no machine file, checking Makefile.global and
pg_config --cppflags each time. Full build with -Dcassert=true passes
meson test, and a PGXS extension using libpq-be.h builds against the
install and passes its regression suite. No aarch64 here, so your run is
still the coverage for that.

Regards,
Aidar

Attachment Content-Type Size
v7-0001-meson-expose-OpenSSL-and-ICU-compiler-flags-to-PG.patch application/octet-stream 8.6 KB
unknown_filename text/plain 2 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2026-11-25 16:51:13 Re: Let OpenSSL auto-select DH parameters by default
Previous Message Álvaro Herrera 2026-11-25 16:41:41 Re: repack: clarify final phase of concurrent mode in file header comment