<div dir="ltr">On the COFF side, I think /verbose already gives `Reading ...` logs. Users can parse the filenames.<br>It probably makes sense to add a fine-grained option /trace as per ELF (-t --trace).<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 31, 2019 at 2:03 AM Rui Ueyama 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"><div dir="ltr">Yes, it's a little bit off-topic, but it is also planned. The data structure that the linker handles can be considered a large graph where vertices are file sections and edges are symbol names. You can say that file A depends on file B if and only if in the graph a section in file A has an edge to a section in file B. There is a plan to dump the graph in a machine-readable format such as JSON so that you can run arbitrary graph analysis algorithms on it.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 31, 2019 at 10:55 AM Shi, Steven <<a href="mailto:steven.shi@intel.com" target="_blank">steven.shi@intel.com</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">
<div lang="EN-US">
<div class="gmail-m_111351311159051365gmail-m_-8129337549807827575gmail-m_3803103687571245022gmail-m_6860700984809400629gmail-m_6706030245267268102WordSection1">
<p class="MsoNormal"><a name="m_111351311159051365_m_-8129337549807827575_m_3803103687571245022_m_6860700984809400629_m_6706030245267268102__MailEndCompose"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Very nice. It can directly help me know which lib and obj file is redundant in my linker script.<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">BTW, besides the lib and file level dependency, is it possible to further print the function and global variable level dependency? E.g. the really linked symbols
before any link level optimization. The fine granularity dependency could help me clean the redundant code and more accurately select regression test case in CI.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Steven</span><b><span style="font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><a name="m_111351311159051365_m_-8129337549807827575_m_3803103687571245022_m_6860700984809400629_m_6706030245267268102______replyseparator"></a><b><span style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif"> Rui Ueyama [mailto:<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>]
<br>
<b>Sent:</b> Wednesday, July 31, 2019 9:29 AM<br>
<b>To:</b> Shi, Steven <<a href="mailto:steven.shi@intel.com" target="_blank">steven.shi@intel.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] RFC: auto-generating build dependency file from lld<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Yeah, I think there's no reason to not add this to lld/COFF if people find it useful.<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jul 31, 2019 at 10:25 AM Shi, Steven <<a href="mailto:steven.shi@intel.com" target="_blank">steven.shi@intel.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I love this feature. Does it plan to support COFF as well?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thanks</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Steven</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span><u></u><u></u></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><a name="m_111351311159051365_m_-8129337549807827575_m_3803103687571245022_m_6860700984809400629_m_6706030245267268102_m_-8764770562920469159_m_582533476218688"></a><b><span style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif">
llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Rui Ueyama via llvm-dev<br>
<b>Sent:</b> Wednesday, July 31, 2019 8:54 AM<br>
<b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [llvm-dev] RFC: auto-generating build dependency file from lld</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I'd like to propose a new feature and a flag (`--write-dependencies=<path>`) for lld so that the linker can generate a dependency file (.d file). This is analogous to `-MD` compiler
flag.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Background:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Clang and GCC have a feature (`-MD` flag) to create a dependency file in a format that `make` and other build tools can read, so that you don't have to manually maintain dependencies
between .c files and .h files. There's no similar feature for the linker, even though it seems useful in some situations.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">In particular, if a compiler driver automatically appends a static library to the final executable but you don't know the exact path of the library, there's currently no way to
keep track of that dependency. A typical example of it is `-fsanitizer=asan` which adds libasan to the linker command line. If libasan is updated, you may want to rebuild your program, but you don't want to manually write its path to a build file because that
may change.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Proposal:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Add a new command line flag `--write-dependencies=<path>` to lld. If the flag is given, lld creates a file at a given path with the following contents:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <output-file>: <input-file> ...<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">where <output-file> is a pathname of an output file and <input-file> ... is a list of pathnames of all input files. This file format is the same as the `-MD` compiler flag output.<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">Here is a change to implement the above feature:
<a href="https://reviews.llvm.org/D65430" target="_blank">https://reviews.llvm.org/D65430</a><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Any comments?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Rui<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote></div>
_______________________________________________<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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">宋方睿</div></div>