<div dir="ltr">The other option is to just pass --verbose to the linker to print out a filename as the linker opens a file.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2019 at 12:44 PM Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.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 dir="ltr">If you want to analyze file dependencies, analyzing command line arguments are perhaps not enough due to archive files (".a" files). The linker pulls up only needed files from archive files, so the dependency to static archive files is somewhat partial.<div><br></div><div>Have you ever tried "-M" linker option? That option lets the linker to print out what files and symbols are included in the output file. If you don't need an actual executable, you could redirect it to /dev/null by passing `-o /dev/null` to the linker. That's might be better choice than analyzing program dependencies yourself.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2019 at 11:54 AM Alexander Linne <<a href="mailto:alexander.linne@outlook.com" target="_blank">alexander.linne@outlook.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 bgcolor="#FFFFFF">
<p>Hi Rui,</p>
<p>what I am trying to achieve is actually getting all input files that are linked into the result, yes.<br>
The first thing I currently try to achieve is to determine the object files that are being linked. My problem there exactly is to decide if an argument without dash belongs to an option or if it is an input file.<br>
</p>
<p>To give some context:<br>
I'm currently trying to write a build analysis tool that works independently of build scripts/systems by tracking calls performed during the build.<br>
Therefore, for a C++ project, I get a list of gcc/clang/ld calls and their command lines. From there I try to build a graph of which source files are built into which object files, libraries, ...<br>
</p>
<div class="gmail-m_2304269661256371215gmail-m_6799887744374573850moz-cite-prefix">On 25.03.2019 19:19, Rui Ueyama wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi Alexander,
<div><br>
</div>
<div>Could you explain a little bit more about what you are trying to achieve? Most of the input files given to a linker is obvious -- if a command line argument does not start with dash and if is not an argument for an option, it is a filename. So I'm guessing
 you want to resolve library file names given by -l. Am I correct?</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2019 at 11:14 AM Alexander Linne via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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">
Hello,<br>
<br>
i am currently trying to write a tool based on lld. Specifically I want <br>
to parse a ld command line to determine the input and output files and <br>
the kind of each input file given a ld command line.<br>
Unfortunately, the ELF linker does not expose any API to just parse the <br>
command line.<br>
My question: if I would refactor this module to expose such an API, <br>
would this have any chance of being merged back into the official <br>
repository?<br>
<br>
Regards<br>
<br>
Alexander Linne<br>
<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://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=02%7C01%7C%7C80bdbf0e91cf4c474ca908d6b14e75a9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636891347866175206&sdata=Lo%2BgWQubdBmD5lzWQf13sCiRfoXhQd%2BmKHRlLb%2BFJfY%3D&reserved=0" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</div>
</blockquote>
</div>

</blockquote></div>
</blockquote></div>