[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
Sat Jun 13 14:57:28 PDT 2020


phosek added a comment.

In D65430#2089961 <https://reviews.llvm.org/D65430#2089961>, @MaskRay wrote:

> I have mentioned this several times. You can just process `-t` output like `{ echo -n 'a: '; clang a.o -o a -Wl,-t | sed 's/(.*//' | sort -u | sed '$!s/$/ \\/';} > a.d`


Your workaround isn't a replacement for `--dependency-file` because `-t` has a different semantics. Proper dependency file tracking has to include files opened and not included in the link after examination, e.g. archives whose contents might influence the link if changed but didn't influence the link this time around.

Also this workaround is deeply unappealing from the perspective of integrating into the build. It's not portable and it assumes you can just invoke arbitrary shell script from your build system which is generally not the case, and certainly not the case for us. It also requires invoking 4 external commands which adds additional overhead. You could address it by creating a wrapper around lld (I'm ignoring the `-t` semantics issue here), but that's almost certainly going to be more complicated and more expensive than this implementation which is 20 lines of code and is unlikely to require any future maintenance.

> The problems are summarized previously and I don't see they are addressed. Given an existing simple way listing dependencies, I don't think we need more -M* like options.

That's easy to address, we can modify the semantics of `--dependency-file` to behave like `-MP` by default which makes this feature usable from both Ninja and Make. The proposed BFD ld and gold implementation <https://sourceware.org/pipermail/binutils/2020-June/111684.html> already behaves that way, I'm happy to update this change to match that.


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