[llvm-dev] lld based tool

Rui Ueyama via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 25 12:47:48 PDT 2019


The other option is to just pass --verbose to the linker to print out a
filename as the linker opens a file.

On Mon, Mar 25, 2019 at 12:44 PM Rui Ueyama <ruiu at google.com> wrote:

> 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.
>
> 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.
>
> On Mon, Mar 25, 2019 at 11:54 AM Alexander Linne <
> alexander.linne at outlook.com> wrote:
>
>> Hi Rui,
>>
>> what I am trying to achieve is actually getting all input files that are
>> linked into the result, yes.
>> 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.
>>
>> To give some context:
>> I'm currently trying to write a build analysis tool that works
>> independently of build scripts/systems by tracking calls performed during
>> the build.
>> 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, ...
>> On 25.03.2019 19:19, Rui Ueyama wrote:
>>
>> Hi Alexander,
>>
>> 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?
>>
>> On Mon, Mar 25, 2019 at 11:14 AM Alexander Linne via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>>> Hello,
>>>
>>> i am currently trying to write a tool based on lld. Specifically I want
>>> to parse a ld command line to determine the input and output files and
>>> the kind of each input file given a ld command line.
>>> Unfortunately, the ELF linker does not expose any API to just parse the
>>> command line.
>>> My question: if I would refactor this module to expose such an API,
>>> would this have any chance of being merged back into the official
>>> repository?
>>>
>>> Regards
>>>
>>> Alexander Linne
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> llvm-dev at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>> <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>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190325/209d4de5/attachment.html>


More information about the llvm-dev mailing list