Re: meson: Allow disabling static libraries

From: Andres Freund <andres(at)anarazel(dot)de>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tristan Partin <tristan(at)partin(dot)io>
Subject: Re: meson: Allow disabling static libraries
Date: 2026-01-20 17:03:30
Message-ID: hbncx2rakvfhnionll4g4y6lxhx23wpr7g4vcncdyocfvlwdbh@e4q7u4pjbuhw
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-01-20 08:03:58 +0100, Peter Eisentraut wrote:
> This patch allows disabling the build of static libraries using the standard
> meson option -Ddefault_library=shared (defaults to "both"). This option
> would work out of the box if you use the library() function to build
> libraries, but we use shared_library() and static_library() separately, for
> reasons that are explained in src/interfaces/libpq/meson.build. So now with
> this, the option works again as expected from the end user's perspective.
>
> This approach was suggested by Tristan Partin over in the AIX thread[0], but
> I figured this could be a generally usable feature, as some distributions
> don't want to build static libraries.

Makes sense to me.

> For illustration and continuous testing, I disabled static libraries in the
> CI SanityCheck task.

Hm. I guess that makes sense.

> The opposite case of disabling shared libraries doesn't work at the moment.
> I think that is much less useful, but if someone wanted to, they could
> implement it in this same framework.

I suspect there are some folks interested in that, although I don't find that
a particularly interesting thing to do personally. It'd certainly a bit weird
to document, since it fundamentally won't work for the server...

> ###############################################################
> @@ -3499,18 +3513,20 @@ endif
> installed_targets = [
> backend_targets,
> bin_targets,
> - libpq_st,
> pl_targets,
> contrib_targets,
> nls_mo_targets,
> ecpg_targets,
> ]
> +if dep_static_lib.found()
> + installed_targets += [libpq_st]
> +endif

Wonder if we ought to define installed_targets = [] earlier and allow
different meson.build files to add themselves, instead of putting knowledge
like this into a central spot.

Separately, perhaps it'd be mildly nicer to have a boolean for static libs
instead of using .found() everywhere.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vitaly Davydov 2026-01-20 17:03:55 Re: Exit walsender before confirming remote flush in logical replication
Previous Message Andres Freund 2026-01-20 16:38:29 Re: Make copyObject work in C++