[llvm-dev] RFC: auto-generating build dependency file from lld

Finkel, Hal J. via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 31 13:32:28 PDT 2019


On 7/30/19 9:03 PM, Rui Ueyama via llvm-dev wrote:
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.


That would be very useful.

 -Hal


On Wed, Jul 31, 2019 at 10:55 AM Shi, Steven <steven.shi at intel.com<mailto:steven.shi at intel.com>> wrote:
Very nice. It can directly help me know which lib and obj file is redundant in my linker script.

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.


Thanks
Steven

From: Rui Ueyama [mailto:ruiu at google.com<mailto:ruiu at google.com>]
Sent: Wednesday, July 31, 2019 9:29 AM
To: Shi, Steven <steven.shi at intel.com<mailto:steven.shi at intel.com>>
Cc: llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>
Subject: Re: [llvm-dev] RFC: auto-generating build dependency file from lld

Yeah, I think there's no reason to not add this to lld/COFF if people find it useful.

On Wed, Jul 31, 2019 at 10:25 AM Shi, Steven <steven.shi at intel.com<mailto:steven.shi at intel.com>> wrote:
I love this feature. Does it plan to support COFF as well?


Thanks
Steven

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>] On Behalf Of Rui Ueyama via llvm-dev
Sent: Wednesday, July 31, 2019 8:54 AM
To: llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>
Subject: [llvm-dev] RFC: auto-generating build dependency file from lld

Hi,

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.

Background:
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.

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.

Proposal:
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:

  <output-file>: <input-file> ...

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.

Here is a change to implement the above feature: https://reviews.llvm.org/D65430

Any comments?

Thanks,
Rui



_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190731/1867ea1f/attachment.html>


More information about the llvm-dev mailing list