[cmake-developers] Recommendations for reducing spurious link dependencies?

Dave Abrahams dave at boostpro.com
Fri Feb 21 22:59:44 EST 2014


Thanks, but as far as I can tell, only static libraries are involved here


On Fri, Feb 21, 2014 at 7:43 PM, Ben Boeckel <ben.boeckel at kitware.com>wrote:

> On Fri, Feb 21, 2014 at 18:53:48 -0800, Dave Abrahams wrote:
> > I'm following up on this recent thread:
> >
> http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/9324/focus=9330
> >
> > Unfortunately, most of what was discussed there appears to involve
> advanced
> > CMake knowledge that I don't have.  Would it be possible for someone to
> > look at the llvm/clang build and make some specific recommendations,
> > perhaps suggesting a procedure I could follow to winnow out the excess
> > dependencies?
>
> My usual process for this is to start with no linked libraries then add
> them in as needed. Detecting this involves writing a little tool which
> dlopen's all built shared libraries with RTLD_NOW and failing if symbols
> are missing. I have test cases which are automatically added for each
> shared library my builds generate to ensure that new dependencies are
> always satisfied.
>
> For a less time-intensive process, the --print-gc-sections and
> --gc-sections linker options may be of help.
>
> The --strip-unneeded option to strip(1) may help, but I doubt it. Maybe
> you could diff the nm -C output between the old and new libraries to see
> if any libraries were dropped?
>
> This[1] PDF states that ldd -u can help as well (but only shows unused
> direct dependencies). There is also a libaudit.so available on github
> which apparently can help as well (see the PDF for the URL and how to
> use it).
>
> For OS X, it appears[2] there is a -dead_strip_dylibs option which
> removes links to libraries which supply no used symbols. I don't know if
> it tells you when that happens.
>
> --Ben
>
> [1]http://elinux.org/images/6/6c/Elc2011_sankar.pdf
> [2]
> https://stackoverflow.com/questions/6687630/c-c-gcc-ld-remove-unused-symbols
>



-- 
Dave Abrahams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140221/0cc44e1b/attachment-0002.html>


More information about the cmake-developers mailing list