Further restrict the scope of no-exit()-in-libpq test.

Disable this check altogether in --enable-coverage builds,
because newer versions of gcc insert exit() as well as abort()
calls for that.  Also disable it on AIX and Solaris, because
those platforms tend to provide facilities such as libldap
as static libraries, which then get included in libpq's shlib.
We can't expect such libraries to honor our coding rules.
(That platform list might need additional tweaking, but I think
this is enough to keep the buildfarm happy.)

Per reports from Jacob Champion and Noah Misch.

Discussion: https://postgr.es/m/3128896.1624742969@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2021-07-03 11:21:40 -04:00
parent d390bb62a6
commit 792259591c

View File

@ -104,12 +104,20 @@ backend_src = $(top_srcdir)/src/backend
# 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 silently insert abort() calls, e.g. when profiling.)
# 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.
# 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.
libpq-refs-stamp: $(shlib)
ifneq ($(enable_coverage), yes)
ifeq (,$(filter aix solaris,$(PORTNAME)))
! nm -A -u $< 2>/dev/null | grep -v __cxa_atexit | grep exit
endif
endif
touch $@
# Make dependencies on pg_config_paths.h visible in all builds.