On 2021-Jun-30, Alvaro Herrera wrote:
> If I remove -fprofile-arcs from CFLAGS, then abort is no longer present,
> but we still get a fail because of __gcov_exit. I suppose if you'd add
> an exception for __cxa_atexit, the same place could use one for
> __gcov_exit.
I tried the attached patch, and while libpq.so now builds successfully,
it causes anything that tries to link to libpq fail like
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement
-Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3
-Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g
-fprofile-arcs -ftest-coverage findtimezone.o initdb.o localtime.o
-L../../../src/port -L../../../src/common -L../../../src/fe_utils -lpgfeutils
-L../../../src/common -lpgcommon -L../../../src/port -lpgport
-L../../../src/interfaces/libpq -lpq -Wl,--as-needed
-Wl,-rpath,'/pgsql/install/master-coverage/lib',--enable-new-dtags -lpgcommon
-lpgport -lpthread -lxml2 -lssl -lcrypto -lz -lreadline -lpthread -lrt -ldl -lm
-o initdb
/usr/bin/ld: initdb: hidden symbol `__gcov_merge_add' in
/usr/lib/gcc/x86_64-linux-gnu/8/libgcov.a(_gcov_merge_add.o) is referenced by
DSO
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:43: initdb] Error 1
so this doesn't look too promising.
--
Álvaro Herrera Valdivia, Chile
https://www.EnterpriseDB.com/
>From db2995171fcf2dad257fdd9d924b1dea916bdbcd Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <[email protected]>
Date: Wed, 30 Jun 2021 09:41:11 -0400
Subject: [PATCH] Fix libpq build for coverage support
---
src/Makefile.shlib | 2 +-
src/interfaces/libpq/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 29a7f6d38c..c549505e44 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -65,7 +65,7 @@
#
-COMPILER = $(CC) $(CFLAGS)
+COMPILER = $(CC) $(filter-out -fprofile-arcs, $(CFLAGS))
LINK.static = $(AR) $(AROPT)
LDFLAGS_INTERNAL += $(SHLIB_LINK_INTERNAL)
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index e8cd07e9c9..8ddb214983 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -108,7 +108,7 @@ backend_src = $(top_srcdir)/src/backend
# complaining about <assert.h> infrastructure on ancient macOS releases.
.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 '_eprintf\.o:' | grep -v '__gcov_exit' | grep -e abort -e 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
--
2.30.2