<div dir="ltr"><div>If you use only one function from a static library, and that adds 80 MiB to the executable, it is clear that that undefined symbol causesĀ a lot of other files to be loaded, so the question is why that function has such a large (transitive) dependency and how to find the cause.</div><div><br></div><div>Unfortunately there's no exact command line option or a feature to find it out. I have an idea to write a post-link analysis tool, which processes a linker's debug output, to find out a "weak link" in a dependency graph. If we can split a graph into two by removing a small number of symbols (or vertices) from the graph, we can reduce a program size by removing these symbols from the program. But that kind of analysis tool is not available yet, and I don't know how powerful it would actually be.</div><div><br></div><div>There are a few options that may be useful when debugging the issue.</div><div><br></div><div>`-v` makes lld to print out a file name as the linker loads a new file.</div><div><br></div><div>`-Map=<filename>` makes lld to write an outputĀ file layout information to a given file.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 7, 2019 at 8:59 PM Carlo Kok via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there any way to find out what causes a 80mb executable with lld/link?<br>
<br>
<br>
The object files are compiled with -function-sections and -data-sections, the originating .lib is 270mb, but I'm calling 1 function in it, which might call some stuff recursively, but I don't know how to find out what exactly triggers the use. Is there a commandline option that shows this?<br>
<br>
(repro is 286 mb) : <a href="http://gofile.me/4Gflq/OOr8WKU12" rel="noreferrer" target="_blank">http://gofile.me/4Gflq/OOr8WKU12</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>