Re: meson's in-tree libpq header search order vs -Dextra_include_dirs

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: meson's in-tree libpq header search order vs -Dextra_include_dirs
Date: 2025-11-01 05:21:35
Message-ID: CA+hUKG+x-cys30=7L2B8=cZ+-z6QDOj-oQy9O3CnkeXnrnm3OQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 1, 2025 at 10:13 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Sat, Nov 1, 2025 at 7:14 AM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> > However, I'm worried that we'll soon break it again. The new rule is
> > apparently "include libpq first", but we have no way of enforcing it.
>
> Hmm, my meson-fu is weak, but there must surely be some way to declare
> that you want libpq and have it automatically put things in the right
> order, will look into that...

If we really don't want every site that depends on both libpq and
frontend_code to have to remember to respect that order when declaring
dependencies, then we could instead change frontend_code to force
libpq_inc to appear in its include_directories before postgres_inc (=
where extra_include_dirs comes from). This one-liner fixes the build
on my system:

# for frontend binaries
frontend_code = declare_dependency(
- include_directories: [postgres_inc],
+ include_directories: [libpq_inc, postgres_inc],

That feels a little odd, because libpq is not really a dependency of
frontend_code, and not all frontend_code users also use libpq (though
almost all do). Does this have any unwanted side-effects? Is there a
better way to do this in a central place?

There are two other places that already have those two in
include_directories already, so their order should surely be flipped
to match, they just didn't happen to break on my system (I guess by
luck, ie not accessing APIs that changed incompatibly since the
version in my system-installed libpq headers).

Attachment Content-Type Size
v2-0001-meson-Fix-libpq-header-inclusion-order.patch text/x-patch 2.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2025-11-01 08:00:00 Re: Improving tracking/processing of buildfarm test failures
Previous Message vignesh C 2025-11-01 05:15:41 Re: Logical Replication of sequences