Re: zlib detection in Meson on Windows broken?

From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "Andres Freund" <andres(at)anarazel(dot)de>, "Dave Page" <dpage(at)pgadmin(dot)org>, "Nazir Bilal Yavuz" <byavuz81(at)gmail(dot)com>
Cc: "PostgreSQL Developers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: zlib detection in Meson on Windows broken?
Date: 2024-05-21 22:09:54
Message-ID: D1FNZQX8L4IB.14B0BH8GILJAT@partin.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue May 21, 2024 at 10:04 AM CDT, Andres Freund wrote:
> Hi,
>
> On 2024-05-20 11:58:05 +0100, Dave Page wrote:
> > I have very little experience with Meson, and even less interpreting it's
> > logs, but it seems to me that it's not including the extra lib and include
> > directories when it runs the test compile, given the command line it's
> > reporting:
> >
> > cl C:\Users\dpage\git\postgresql\build\meson-private\tmpg_h4xcue\testfile.c
> > /nologo /showIncludes /utf-8 /EP /nologo /showIncludes /utf-8 /EP /Od /Oi-
> >
> > Bug, or am I doing something silly?
>
> It's a buglet. We rely on meson's internal fallback detection of zlib, if it's
> not provided via pkg-config or cmake. But it doesn't know about our
> extra_include_dirs parameter. We should probably fix that...

Here is the relevant Meson code for finding zlib in the Postgres tree:

postgres_inc_d = ['src/include']
postgres_inc_d += get_option('extra_include_dirs')
...
postgres_inc = [include_directories(postgres_inc_d)]
...
zlibopt = get_option('zlib')
zlib = not_found_dep
if not zlibopt.disabled()
zlib_t = dependency('zlib', required: zlibopt)

if zlib_t.type_name() == 'internal'
# if fallback was used, we don't need to test if headers are present (they
# aren't built yet, so we can't test)
zlib = zlib_t
elif not zlib_t.found()
warning('did not find zlib')
elif not cc.has_header('zlib.h',
args: test_c_args, include_directories: postgres_inc,
dependencies: [zlib_t], required: zlibopt)
warning('zlib header not found')
elif not cc.has_type('z_streamp',
dependencies: [zlib_t], prefix: '#include <zlib.h>',
args: test_c_args, include_directories: postgres_inc)
if zlibopt.enabled()
error('zlib version is too old')
else
warning('zlib version is too old')
endif
else
zlib = zlib_t
endif

if zlib.found()
cdata.set('HAVE_LIBZ', 1)
endif
endif

You can see that we do pass the include dirs to the has_header check.
Something seems to be going wrong here since your extra_include_dirs
isn't being properly translated to include arguments.

--
Tristan Partin
https://tristan.partin.io

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Imseih (AWS), Sami 2024-05-21 23:15:14 Re: problems with "Shared Memory and Semaphores" section of docs
Previous Message Pavel Stehule 2024-05-21 21:14:43 Re: Schema variables - new implementation for Postgres 15