Обсуждение: Re: meson's in-tree libpq header search order vs -Dextra_include_dirs

Поиск
Список
Период
Сортировка

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

От
"Tristan Partin"
Дата:
On Sun Feb 2, 2025 at 6:29 PM CST, Thomas Munro wrote:
> When I use configure/make and --with-includes=/usr/local/include, I
> see compile lines like this:
>
> ... -I../../src/interfaces/libpq -I../../src/include  -I/usr/local/include ...
>
> That's important, because if I happen to have libpq headers installed
> on the system I don't want to be confused by them.  Yet meson's
> -Dextra_include_dirs=/usr/local/include compiles like this:
>
> ... -I../src/include -I/usr/local/include -Isrc/interfaces/libpq ...
>
> ... which gives me errors due to the v16 headers I happen to have installed:
>
> ../src/fe_utils/connect_utils.c:164:3: error: unknown type name
> 'PGcancelConn'; did you mean 'PGcancel'?
>   164 |                 PGcancelConn *cancelConn = PQcancelCreate(conn);
>
> I guess this affects Macs, BSDs and a few lesser used Linux distros
> that put optional packages outside the base system and default search
> paths.  Perhaps you can see this on everything-goes-into-base-system
> distros if you redundantly say -Dextra_include_dirs=/usr/include; I
> didn't check if that is true, it wouldn't be if meson is opinionated
> enough to remove it.

What is the benefit of -Dextra_include_dirs when you could use -Dc_flags
or CFLAGS to specify extra include directories? If you tried either of
those as an alternative, would they fix the issue? The existence of the
option goes all the way back to the initial commit of the meson port, so
I presume it exists to mirror --with-includes, but why does that exist?

--
Tristan Partin
Databricks (https://databricks.com)



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

От
Tom Lane
Дата:
"Tristan Partin" <tristan@partin.io> writes:
> What is the benefit of -Dextra_include_dirs when you could use -Dc_flags 
> or CFLAGS to specify extra include directories? If you tried either of 
> those as an alternative, would they fix the issue? The existence of the 
> option goes all the way back to the initial commit of the meson port, so 
> I presume it exists to mirror --with-includes, but why does that exist?

--with-includes, and likewise --with-libs, exist because there are
platforms that require it.  For example, on pretty much any
BSD-derived system, the core /usr/include and /usr/lib files are very
limited and you'll need to point at places like /usr/pkg/include or
/opt/local/include or whatever to pull in non-core packages.

I see your point about putting -I flags into CFLAGS, but what you
are missing is that the order of these flags is unbelievably critical,
so "just shove it into CFLAGS" is a recipe for failure, especially
if you haven't even stopped to think about which end to add it at.
We've learned over decades of trial-and-error with the makefile system
that treating -I and -L flags specially is more reliable.  (See for
example all the logic in our autoconf scripts to forcibly separate
-I and -L out of sources like pkg-config.  Tracing that stuff back to
the originating commits and mail discussions would be a constructive
learning exercise.)

I'm not sure that the meson crew have learned all that yet.
But this does not suggest to me that they know more than we do.

            regards, tom lane