libpq: Refactor logic checking for exit() in shared library builds
authorMichael Paquier <michael@paquier.xyz>
Tue, 9 Dec 2025 01:39:08 +0000 (10:39 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 9 Dec 2025 01:39:08 +0000 (10:39 +0900)
commit4a8e6f43a6b56289cd3806b239c20ae31aa4cf2e
tree2bf2aaa65eb0111671e127118a375630b7cf5bbc
parentc004d68c9395812bfcff82c2d7c4e56d36e72f1c
libpq: Refactor logic checking for exit() in shared library builds

This commit refactors the sanity check done by libpq to ensure that
there is no exit() reference in the build, moving the check from a
standalone Makefile rule to a perl script.

Platform-specific checks are now part of the script, avoiding most of
the duplication created by the introduction of this check for meson, but
not all of them:
- Solaris and Windows skipped in the script.
- Whitelist of symbols is in the script.
- nm availability, with its path given as an option of the script.  Its
execution is checked in the script.
- Check is disabled if coverage reports are enabled.  This part is not
pushed down to the script.
- Check is disabled for static builds of libpq.  This part is filtered
out in each build script.

A trick is required for the stamp file, in the shape of an optional
argument that can be given to the script.  Meson expects the stamp in
output and uses this argument, generating the stamp file in the script.
Meson is able to handle the removal of the stamp file internally when
libpq needs to be rebuilt and the check done again.

This refactoring piece has come up while discussing the addition of more
items in the symbols considered as acceptable.

This sanity check has never been run by meson since its introduction in
dc227eb82ea8, so it is possible that this fails in some of the buildfarm
members.  At least the CI is happy with it, but let's see how it goes.

Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Co-authored-by: VASUKI M <vasukim1992002@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/19095-6d8256d0c37d4be2@postgresql.org
configure
configure.ac
meson.build
src/Makefile.global.in
src/interfaces/libpq/Makefile
src/interfaces/libpq/libpq_check.pl [new file with mode: 0755]
src/interfaces/libpq/meson.build