Re: meson: Allow disabling static libraries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tristan Partin <tristan(at)partin(dot)io>
Subject: Re: meson: Allow disabling static libraries
Date: 2026-02-18 18:39:05
Message-ID: 2064894.1771439945@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> On 20.01.26 18:03, Andres Freund wrote:
>> Separately, perhaps it'd be mildly nicer to have a boolean for static libs
>> instead of using .found() everywhere.

> Yeah, after playing with this a bit more, I'm not sure sure this
> disabler trick is really that good. The idea would have been that you
> just need to add the disabler to the dependencies and everything else
> will magically work. But the reason that you need stuff like
> +if dep_static_lib.found()
> + installed_targets += [libpq_st]
> +endif
> is that the disabler sneaks up into other variables and dependencies and
> has weird effects. For example, if you remove "if" around this and
> similar lines, then "meson test" breaks in highly confusing ways
> (probably because tmp_install depends on installed_targets).

That seems like an excellent reason to stay away from disabler()
and use your "variant 2". I reviewed/tested this and noted a couple
of other problems:

1. This doesn't work for AIX, because there we'll need to force
build_static_lib to false and yet we'll still want (by default anyway)
to install libpgcommon.a and friends. In the attached I dealt with
that by breaking build_static_lib into two variables, build_static_lib
and install_internal_static_lib.

2. As written, this resulted in installing libpgcommon_srv.a and
libpgport_srv.a, whereas historically we've only installed the
frontend and shlib variants of those libraries. I do not see a
reason to change that behavior. I fixed it in the attached with

+ 'install': install_internal_static_lib and name != '_srv',

but perhaps there's a nicer way?

I think the attached v3 is about ready to go, with perhaps two
loose ends for you to deal with:

* Do we need to document this in the SGML docs?

* Given that -Ddefault_library=static doesn't actually work and
I doubt we have any interest in ever making it work, perhaps
it would be nicer to throw an explicit 'not supported' error.
As this stands, if you try it you get
src/interfaces/libpq/meson.build:89:0: ERROR: Unknown variable "libpq_so".
which looks more like a bug than an intentionally-unsupported option.

regards, tom lane

Attachment Content-Type Size
v3-0001-meson-allow-disabling-building-installation-of-st.patch text/x-diff 11.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-02-18 18:47:45 Re: centralize CPU feature detection
Previous Message Heikki Linnakangas 2026-02-18 18:07:43 Re: Use standard die() handler for SIGTERM in bgworkers