diff --git a/src/common/Makefile b/src/common/Makefile
index f281762885..d0bbaefb1e 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -88,13 +88,18 @@ OBJS_COMMON += sha2.o
 endif
 
 # A few files are currently only built for frontend, not server
-# (Mkvcbuild.pm has a copy of this list, too)
+# (Mkvcbuild.pm has a copy of this list, too).  logging.c is
+# explicitely excluded from the shared library as it enforces some
+# global state used for error reporting, that should never be used
+# by libpq or similar.
 OBJS_FRONTEND = \
 	$(OBJS_COMMON) \
 	fe_memutils.o \
-	logging.o \
 	restricted_token.o \
 	sprompt.o
+OBJS_PGCOMMON = \
+	$(OBJS_FRONTEND) \
+	logging.o
 
 # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
 OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o)
@@ -121,7 +126,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
 	rm -f '$(DESTDIR)$(libdir)/libpgcommon_shlib.a'
 
-libpgcommon.a: $(OBJS_FRONTEND)
+libpgcommon.a: $(OBJS_PGCOMMON)
 	rm -f $@
 	$(AR) $(AROPT) $@ $^
 
@@ -177,7 +182,7 @@ $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 # kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
-	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
+	rm -f $(OBJS_PGCOMMON) $(OBJS_SHLIB) $(OBJS_SRV)
 
 maintainer-clean: distclean
 	rm -f kwlist_d.h
