Thread
-
Re: BUG #19095: Test if function exit() is used fail when linked static
Michael Paquier <michael@paquier.xyz> — 2025-11-24T21:43:43Z
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