| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Andres Freund <andres(at)anarazel(dot)de> |
| 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-27 14:03:03 |
| Message-ID: | ca252267-dae0-402c-b44c-030e6ee812b0@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 20.01.26 18:03, Andres Freund wrote:
>> ###############################################################
>> @@ -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.
Right. See attached patch 0001. This introduces a variable
libpq_targets and populates it in the subdirectories. This moves the
knowledge away from the top-level meson.build.
> 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).
So I think, since we have to have these conditionals, we might as well
put them around the whole static_library() call. And then we can use a
straightforward Boolean variable, like you suggest. See attached patch
0003 (which is on top of 0002, so it would make more sense to view the
diff 0001..0003).
This is also more robust because you get explicit errors for example if
you use libpq_st or libpq_so when they are disabled, instead of
sometimes silently doing nothing.
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-meson-Refactor-libpq-targets-variables.patch | text/plain | 2.9 KB |
| v2-0002-meson-Allow-disabling-static-libraries.patch | text/plain | 10.3 KB |
| v2-0003-meson-Allow-disabling-static-libraries-variant-2.patch | text/plain | 10.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Fujii Masao | 2026-01-27 13:51:01 | Re: display hot standby state in psql prompt |