[Xcb] Demoting xcb* Requires libraries/packages to Requires.private ?

Emil Velikov emil.l.velikov at gmail.com
Sat Aug 2 08:29:17 PDT 2014

Hello all,

After a bit of interesting experience with xcb+mesa I've noticed that all xcb
modules list their requirements in the non-private pkg-config variable/section.

While this is not wrong/incorrect, it causes any program that links against a
xcb module to link against the module's deps, causing overlinking. Also it
hides some of the true dependencies as they may be implicitly pulled via the
Requires section.

What is overlinking:

   "example: when emacs build with libpng support, it uses -lz in case we're
    linking with a static PNG library. Alas this is bad when doing dynamic
    linking: if we update zlib to a new major version, emacs will have to be
    rebuilt, even if emacs doesn't use it all, only libpng does." [0]

How to check for overlinking:

    $ ldd -u -r /file/to/check

Some supporting material

  "Requires and Requires.private define other modules needed by the library.
   It is usually preferred to use the private variant of Requires to avoid
   exposing unnecessary libraries to the program that is linking with your
   library. If the program will not be using the symbols of the required
   library, it should not be linking directly to that library. See the
   discussion of overlinking for a more thorough explanation." [1]

One of the ways to resolve overlinking:

  "Some software uses $(pkg-config --libs somefoo) to get the needed linker
   flags. Pkg-config uses the "Libs:" and "Requires:" entry from *.pc file to
   get the linker flags.

   However, many *.pc files incorrectly specify their own dependencies in
   "Libs:" or "Requires:" while their own dependencies should be in
   "Libs.private:" and "Requires.private:".<ref>they are historical reasons
   for this: Requires.private and Libs.private were not existing in early
   pkgconfig (before 0.18) and were not backward compatible.</ref>" [2]

As far as I can see, pkg-config 0.18 was released nearly 10 years ago (~June
2005) and all of the currently supported distributions use version greater
than that.

    Ubuntu 10.04 LTS		- 0.22
    Debian Squeeze (oldstable)	- 0.25
    Fedora 19			- 0.27.1
    RHEL 5 (RHEL 4 anyone ?)	- 0.21
    OpenSUSE 12.2		- 0.25
    SUSE SLE-11 SP2		- 0.25 (third party repo)

As such, would there be any objections doing a sed job through libxcb as seen
below ?

    $ sed -i "s|Requires:|Requires.private:|g" {check-pc-requires,*.in}


P.S. Please keep me in the Cc list as I'm not subscribed to the ML.

[0] https://wiki.mageia.org/en/Overlinking_issues_in_packaging#What_is_overlinking
[1] http://people.freedesktop.org/~dbn/pkg-config-guide.html
[2] https://wiki.mageia.org/en/Overlinking_issues_in_packaging#pkgconfig_issues

While in the context of xcb,

More information about the Xcb mailing list