[llvm-dev] LLD/Link find out what triggers 80mb exe

Rui Ueyama via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 7 05:22:09 PDT 2019


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.

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.

There are a few options that may be useful when debugging the issue.

`-v` makes lld to print out a file name as the linker loads a new file.

`-Map=<filename>` makes lld to write an output file layout information to a
given file.

On Fri, Jun 7, 2019 at 8:59 PM Carlo Kok via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Is there any way to find out what causes a 80mb executable with lld/link?
>
>
> 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?
>
> (repro is 286 mb) : http://gofile.me/4Gflq/OOr8WKU12
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190607/04faad48/attachment.html>


More information about the llvm-dev mailing list