Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 06843df

Browse files
committed
Suppress macOS warnings about duplicate libraries in link commands.
As of Xcode 15 (macOS Sonoma), the linker complains about duplicate references to the same library. We see warnings about libpgport and libpgcommon being duplicated in many client executables. This is a consequence of the hack introduced in commit 6b7ef07 to list libpgport before libpq while not removing it from $(LIBS). (Commit 8396447 later applied the same rule to libpgcommon.) The concern in 6b7ef07 was to ensure that the client executable wouldn't unintentionally depend on pgport functions from libpq. That concern is obsolete on any platform for which we can do symbol export control, because if we can then the pgport functions in libpq won't be exposed anyway. Hence, we can fix this problem by just removing libpgport and libpgcommon from $(libpq_pgport), and letting clients depend on the occurrences in $(LIBS). In the back branches, do that only on macOS (which we know has symbol export control). In HEAD, let's be more aggressive and remove the extra libraries everywhere. The only still-supported platforms that lack export control are MinGW/Cygwin, and it doesn't seem worth sweating over ABI stability details for those (or if somebody does care, it'd probably be possible to perform symbol export control for those too). As well as being simpler, this might give some microscopic improvement in build time. The meson build system is not changed here, as it doesn't have this particular disease, though it does have some related issues that we'll fix separately. Discussion: https://postgr.es/m/467042.1695766998@sss.pgh.pa.us
1 parent 75af0f4 commit 06843df

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Makefile.global.in

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,27 @@ endif
589589
libpq = -L$(libpq_builddir) -lpq
590590

591591
# libpq_pgport is for use by client executables (not libraries) that use libpq.
592-
# We force clients to pull symbols from the non-shared libraries libpgport
593-
# and libpgcommon rather than pulling some libpgport symbols from libpq just
594-
# because libpq uses those functions too. This makes applications less
595-
# dependent on changes in libpq's usage of pgport (on platforms where we
596-
# don't have symbol export control for libpq). To do this we link to
597-
# pgport before libpq. This does cause duplicate -lpgport's to appear
598-
# on client link lines, since that also appears in $(LIBS).
592+
# We used to use this to force libpgport and libpgcommon to be linked before
593+
# libpq, ensuring that clients would pull symbols from those libraries rather
594+
# than possibly getting them from libpq (and thereby having an unwanted
595+
# dependency on which symbols libpq uses). However, now that we can prevent
596+
# libpq from exporting those symbols on all platforms of interest, we don't
597+
# worry about that anymore. The previous technique resulted in duplicate
598+
# libraries in link commands, since those libraries also appear in $(LIBS).
599+
# Some platforms warn about that, so avoiding those warnings is now more
600+
# important. Hence, $(libpq_pgport) is now equivalent to $(libpq), but we
601+
# still recommend using it for client executables in case some other reason
602+
# appears to handle them differently.
603+
libpq_pgport = $(libpq)
604+
599605
# libpq_pgport_shlib is the same idea, but for use in client shared libraries.
606+
# We need those clients to use the shlib variants. (Ideally, users of this
607+
# macro would strip libpgport and libpgcommon from $(LIBS), but no harm is
608+
# done if they don't, since they will have satisfied all their references
609+
# from these libraries.)
600610
ifdef PGXS
601-
libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
602611
libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
603612
else
604-
libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
605613
libpq_pgport_shlib = -L$(top_builddir)/src/common -lpgcommon_shlib -L$(top_builddir)/src/port -lpgport_shlib $(libpq)
606614
endif
607615

0 commit comments

Comments
 (0)