Fix portability fallout from commit dc227eb82.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Jun 2021 14:52:20 +0000 (10:52 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Jun 2021 14:52:20 +0000 (10:52 -0400)
Give up on trying to mechanically forbid abort() within libpq.
Even though there are no such calls in the source code, we've now
seen three different scenarios where build toolchains silently
insert such calls: gcc does it for profiling, some platforms
implement assert() using it, and icc does so for no visible reason.
Checking for accidental use of exit() seems considerably more
important than checking for abort(), so we'll settle for doing
that for now.

Also, filter out __cxa_atexit() to avoid a false match.  It seems
that OpenBSD inserts a call to that despite the fact that libpq
contains no C++ code.

Discussion: https://postgr.es/m/3128896.1624742969@sss.pgh.pa.us

src/interfaces/libpq/Makefile

index e8cd07e9c9996155d4e183ed724eaed19b50f2c1..c2a35a488af924c60a0b0a3ee85c628d4da3f185 100644 (file)
@@ -102,13 +102,15 @@ all: all-lib check-libpq-refs
 include $(top_srcdir)/src/Makefile.shlib
 backend_src = $(top_srcdir)/src/backend
 
-# Check for functions that libpq must not call, currently abort() and exit().
-# If nm doesn't exist or doesn't work on shlibs, this test will silently
-# do nothing, which is fine.  The exclusion of _eprintf.o is to prevent
-# complaining about <assert.h> infrastructure on ancient macOS releases.
+# 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.)
+# 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.
 .PHONY: check-libpq-refs
 check-libpq-refs: $(shlib)
-   ! nm -A -g -u $< 2>/dev/null | grep -v '_eprintf\.o:' | grep -e abort -e exit
+   ! nm -A -g -u $< 2>/dev/null | grep -v __cxa_atexit | grep exit
 
 # Make dependencies on pg_config_paths.h visible in all builds.
 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h