[PATCH] D65430: Add `--dependency-files` option, which is equivalent to compiler option -MD.

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 01:03:16 PDT 2020


phosek added a comment.

The requirement for this feature came up again recently in our build so I'd like to revive this discussion, is there any way we could get this change landed?

In D65430#1755644 <https://reviews.llvm.org/D65430#1755644>, @bd1976llvm wrote:

> Hi All, Apologies that I missed the request for input here.
>
> Great summary @MaskRay. I like the examples. Worth being careful as dependency graph problems are tricky (I find).
>
> Firstly, the problem that you have raised here is already addressed for header files with -MP, no? Therefore, I think that in lld we simply need to implement the following set: -M, -MM, -MF, -MG, -MP, -MQ, -MD, -MMD. We can presumably reuse the clang code for this so it won't be too bad.
>
> Secondly, you have a point about these being make specific options; however, that is the well established standard. I would support implementing make specific output now and then implementing whatever more generic format build systems standardize on later. Just my 2 cents.
>
> Incidentally, autolinking was modeled on the Microsoft feature where this problem does not exist - thanks to the infamous tracker.exe.
>
> Finally, I don't think that this is as useful a feature (as header file dep generation) because, unlike header files which are not build outputs (usually), libraries are often build outputs. So, although implementing the -M options in LLD would handle incremental builds, you still need to add explicit edges to your makefiles to handle the initial build. If you are having to modify your makefiles then "comment lib" pragmas seem less useful. As I understand it autolinking is intended for linking libraries that are not built by your makefiles e.g. system libraries, or libraries supplied by thirdparty vendors.


This intended use case for this feature is for libraries that are not part of the build, i.e. system libraries and libraries supplied by vendors. We would like to relink the target if the library changes, but today there's no way to do that. When you pass e.g. `-lz` or use `#pragma comment(lib, "z")`, linker might resolve this to `/path/to/libz.a`. Whenever this library gets updated we would like to relink any target that depends on this library. This is a very similar use case to header files where depfiles are typically used to track dependency on system headers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65430/new/

https://reviews.llvm.org/D65430





More information about the llvm-commits mailing list