<div dir="ltr">Thanks, but as far as I can tell, only static libraries are involved here</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 21, 2014 at 7:43 PM, Ben Boeckel <span dir="ltr"><<a href="mailto:ben.boeckel@kitware.com" target="_blank">ben.boeckel@kitware.com</a>></span> wrote:<br>

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