On 2011-11-23 11:11+0100 Rolf Eike Beer wrote:

On 11/23/2011 10:25 AM, Alan W. Irwin wrote:

In sum, from this experiment it looks like I will have to set
LINK_INTERFACE_LIBRARIES to empty for all PLplot library targets that
depend on other library targets (e.g., B, C, D, and E, above, but _not_
main or A) created by our build system to comprehensively turn off
transitive linking and avoid overlinking that rpmlint is complaining
about.

Transitive linking is a tricky issue, especially if the new
--no-copy-dt-needed-entries default is active which means that if you
have e.g. a library A, a library B that links against A and an
executable C that uses symbols from both, A and B but only directly
links against B, you will get a linking error if --as-needed is enabled.

And the linker is absolutely right here: you have not linked against a
library you used symbols from. This has always been broken and works only
by accident. This should fail. This must fail. Setting
LINK_INTERFACE_LIBRARIES to empty to allow the linker detect this is a
good thing.

However, CMake can't know for you whether C actually needs to be linked
against A, so it takes the safe route. The alternative would be to not
do it, but then you would need to explicitly link C against A. See
http://wiki.debian.org/ToolChain/DSOLinking for more details.

And that would be a good thing, too.

The rules are absolutely simple (leaving dynamic plugins and dlopen()
stuff out): if you use a symbol from a library you have to link against
that library. And I don't see any value in helping people to ignore even
this absolutely basic rule of programming.

I agree. I have attempted to enforce that rule in the PLplot build
system for a long time by only mentioning the relevant directly linked
shared libraries using target_link_libraries, but it appears now I have a
tool (i.e. specify an empty LINK_INTERFACE_LIBRARIES for all
libraries) with CMake to make sure all relevant shared libraries are
mentioned and a tool with "ldd -u" to make sure that no irrelevant
shared libraries are mentioned.

That leaves the topic of whether transitive linking is ever required
(assuming you have done due diligence about the shared libraries that
need to be directly linked). I know that Linux demanded transitive
linking in the old days, and CMake certainly still uses transitive
linking by default. So my question is whether some "enterprise" Linux
distros or some existing Mac OS X, other Unix, or Windows platforms
still demand transitive linking of shared libraries.  If so, I would
turn off transitive linking for the PLplot build system only as an
experimental option so as not to interfere with PLplot building and
running on all platforms.  If not, should the CMake transitive linking
default for shared libraries be deprecated with a note in the
documentation that recommends using an empty LINK_INTERFACE_LIBRARIES?

Comments on platform issues (if any are left) with transitive linking
of shared libraries would be welcome.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to