[cmake-developers] Proposal to disable link depends inference.

Matthew Hanna (BLOOMBERG/ 731 LEX) mhanna21 at bloomberg.net
Tue Apr 11 09:34:54 EDT 2017


Hi,

The inference logic in cmComputeLinkDepends.cxx is both inefficient and
superfluous for our specific use case.  I am proposing a global setting that
would disable the link computation entirely for those that wish to take full
responsibility of the ordering of dependencies.

We are currently using the FindPkgConfig module for generating link lines.
Following the pkg-config guidance, dependencies on system libraries are noted
in the "Libs" section of the pkg-config file as opposed to the "Requires"
section.  This means that common system libraries such as rt are repeated on
the link line.  Unfortunately, this appears to be causing the inference in
cmComputeLinkDepends.cxx to construct highly connected graphs resulting in
delays of several minutes.

For example, consider package X that depends on Y, where both depend on rt.
Since rt is a system library, pkg-config generates -lX -lrt -lY -lrt.  Now
there appears to be a cyclic dependency between rt and Y that the link logic
will attempt to grapple with.  The same problem can also occur even when
pkg-config files only contain a single unique library.  This is because the
output is not well ordered, so two targets might have the order of independent
libraries reversed, and I believe the inference is done globally, so a cycle
inference is possible.  As the number of dependent libraries increases, the
number of edges in the inferred graph explodes.

We have attempted to optimize the algorithm by removing redundant edges, but
this has only had marginal effects.  Assuming that we wish to take
responsibility for avoiding cycles, I would like a mechanism to disable the
inference logic.  One approach would be to extend the semantics of
LINK_INTERFACE_MULTIPLICITY such that setting it to 1 would disable inference
and leave link lines untouched.  However, since this is largely a property of
the library set as opposed to a single target, I would prefer a way to disable
inference at a global level, such as in a custom toolchain file.

Matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170411/5ad2cc6f/attachment-0001.html>


More information about the cmake-developers mailing list