Re: BUG #19095: Test if function exit() is used fail when linked static

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, BharatDB <bharatdbpg(at)gmail(dot)com>, torsten(dot)rupp(at)gmx(dot)net, pgsql-bugs(at)lists(dot)postgresql(dot)org, VASUKI M <vasukim1992002(at)gmail(dot)com>
Subject: Re: BUG #19095: Test if function exit() is used fail when linked static
Date: 2025-11-24 21:43:43
Message-ID: aSTRj99MkyI5zr0y@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Nov 24, 2025 at 02:04:01PM +0300, Nazir Bilal Yavuz wrote:
> Apparently we do not need to remove the stamp-file in the perl script,
> meson already handles that internally. v2 is attached.

Good idea to embed that in a perl script!

> +# Check for functions that libpq must not call, currently just exit().
> +# (Ideally we'd reject abort() too, but there are various scenarios where
> +# build toolchains insert abort() calls, e.g. to implement assert().)
> +# If nm doesn't exist or doesn't work on shlibs, this test will do nothing,
> +# which is fine. The exclusion of __cxa_atexit is necessary on OpenBSD,
> +# which seems to insert references to that even in pure C code. Excluding
> +# __tsan_func_exit is necessary when using ThreadSanitizer data race detector
> +# which use this function for instrumentation of function exit.
> +# Skip the test when profiling, as gcc may insert exit() calls for that.
> +# Also skip the test on platforms where libpq infrastructure may be provided
> +# by statically-linked libraries, as we can't expect them to honor this
> +# coding rule.

Including a reference to "nm" in this comment for meson is definitely
fine, because it is used as a pre-check in this code with
find_program. However, shouldn't we document the platform-specific
exclusions in the perl script itself? As of the patch, the
explanation is a copy-paste of src/interfaces/libpq/Makefile. I think
that we'd better group everything together, rather than have the same
contents explained in two places. Perhaps I would add an extra
comment in meson.build and the Makefile to document that all the
platform-relevant details are in the perl script itself.

I would be also tempted to move the solaris check inside the perl
script rather than have it duplicated across meson and make, then do
something based on $Config{osname} instead.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message VASUKI M 2025-11-25 09:11:32 Re: BUG #19095: Test if function exit() is used fail when linked static
Previous Message PG Bug reporting form 2025-11-24 19:49:04 BUG #19334: Cannot download packages from the mirrors

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-11-24 21:50:26 Re: [PATCH] Add error hints for invalid COPY options
Previous Message Peter Smith 2025-11-24 21:41:05 Re: Skipping schema changes in publication