<div dir="ltr">Yeah, I think there's no reason to not add this to lld/COFF if people find it useful.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">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:<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_-8764770562920469159gmail-m_5825334762186882434WordSection1">
<p class="MsoNormal"><a name="m_-8764770562920469159_m_5825334762186882434__MailEndCompose"><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?<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)"><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<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>
<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_-8764770562920469159_m_5825334762186882434______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"> 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<u></u><u></u></span></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>