[avahi] [PATCH] use Libs.private to avoid DT_NEEDED pollution when building shared

Nix nix at esperi.org.uk
Thu Nov 24 07:07:15 PST 2005


Currently, Avahi specifies all libraries it exposes and all that it uses
internally on the Libs line in the pkg-config file.

For static linking, this is fine, but for shared linking on platforms
supporting shared library dependency chasing (i.e., virtually all of
them), it causes significant problems, as unnecessary libraries get
added to the link line and thus wired in as a mandatory dependency
of the calling program too.

Example:

The library:

- libavahi-client.so
   - libavahi-common.so

Some user, which uses functions from -client's exposed interface only:

- some-user
  - libavahi-common.so   <---
  - libavahi-client.so
     - libavahi-common.so

Note that unnecessary extra dependency.

The problem here is that if libavahi-common breaks its ABI and bumps its
soname, but libavahi-common does not (fairly likely as libavahi-common
is entirely an internal library that is not exposed, as I understand
it), as it is, *every user of libavahi-client.so will need to relink*,
even though no interfaces in libavahi-client.so have changed and its
soname remains unchanged.

This has a very severe impact with widely-used libraries, with major
distros going so far as to entirely disable pkg-config dependency
chasing because the pollution was getting so extreme. (For instance,
virtually everything in GNOME has a DT_NEEDED dependency on libdb-*.so,
even though hardly anything uses it, leading to massive unnecessary
pain whenever libdb bumps its soname.)


Thankfully, after much screaming from the distributors pkg-config
grew a new field, Libs.private: things in this field get exposed on the
link line *only* when linking statically. (It requires pkg-config 0.18,
but so do recent versions of GNOME and KDE, so this is unlikely to be
much of a problem...)

This makes avahi use it. (Massive patch-bombing coming soon as I try to
make GNOME and KDE use it, too).

Index: avahi/avahi-client.pc.in
===================================================================
--- avahi/avahi-client.pc.in	(revision 1025)
+++ avahi/avahi-client.pc.in	(working copy)
@@ -6,5 +6,6 @@
 Name: avahi-client
 Description: Avahi Multicast DNS Responder (Client Support)
 Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lavahi-common -lavahi-client
+Libs: -L${libdir} -lavahi-client
+Libs.private: -lavahi-common
 Cflags: -D_REENTRANT -I${includedir}
Index: avahi/avahi-core.pc.in
===================================================================
--- avahi/avahi-core.pc.in	(revision 1025)
+++ avahi/avahi-core.pc.in	(working copy)
@@ -6,5 +6,6 @@
 Name: avahi-core
 Description: Avahi Multicast DNS Responder (Embeddable Stack)
 Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lavahi-common -lavahi-core
+Libs: -L${libdir} -lavahi-core
+Libs.private: -lavahi-common
 Cflags: -D_REENTRANT -I${includedir}
Index: avahi/avahi-qt3.pc.in
===================================================================
--- avahi/avahi-qt3.pc.in	(revision 1025)
+++ avahi/avahi-qt3.pc.in	(working copy)
@@ -7,5 +7,6 @@
 Description: Avahi Multicast DNS Responder (QT3 Support)
 Version: @PACKAGE_VERSION@
 Requires: qt-mt >= 3.0.0
-Libs: -L${libdir} -lavahi-common -lavahi-qt3
+Libs: -L${libdir} -lavahi-qt3
+Libs.private: -lavahi-common
 Cflags: -D_REENTRANT -I${includedir}
Index: avahi/avahi-qt4.pc.in
===================================================================
--- avahi/avahi-qt4.pc.in	(revision 1025)
+++ avahi/avahi-qt4.pc.in	(working copy)
@@ -7,5 +7,6 @@
 Description: Avahi Multicast DNS Responder (QT4 Support)
 Version: @PACKAGE_VERSION@
 Requires: QtCore >= 4.0.0
-Libs: -L${libdir} -lavahi-common -lavahi-qt4
+Libs: -L${libdir} -lavahi-qt4
+Libs.private: -lavahi-common
 Cflags: -D_REENTRANT -I${includedir}
Index: avahi/avahi-glib.pc.in
===================================================================
--- avahi/avahi-glib.pc.in	(revision 1025)
+++ avahi/avahi-glib.pc.in	(working copy)
@@ -7,5 +7,6 @@
 Description: Avahi Multicast DNS Responder (GLib Support)
 Version: @PACKAGE_VERSION@
 Requires: glib-2.0
-Libs: -L${libdir} -lavahi-common -lavahi-glib
+Libs: -L${libdir} -lavahi-glib
+Libs.private: -lavahi-common
 Cflags: -D_REENTRANT -I${includedir}

-- 
`Y'know, London's nice at this time of year. If you like your cities
 freezing cold and full of surly gits.' --- David Damerell



More information about the avahi mailing list