This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Compute command-lines for dependencies immediately
ClosedPublic

Authored by benlangmuir on Aug 15 2022, 6:06 PM.

Details

Summary

Instead of delaying the generation of command-lines to after all
dependencies are reported, compute them immediately. This is partly in
preparation for splitting the TU driver command into its constituent cc1
and other jobs, but it also just simplifies working with the compiler
invocation for modules if they are not "without paths".

Also change the computation of the default output path in
clang-scan-deps to scrape the implicit module cache from the
command-line rather than get it from the dependency, since that is now
unavailable at the time we make the callback.

Diff Detail

Event Timeline

benlangmuir created this revision.Aug 15 2022, 6:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 6:06 PM
benlangmuir requested review of this revision.Aug 15 2022, 6:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 6:06 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 accepted this revision.Aug 16 2022, 10:29 AM

LGTM overall with some minor nitpicks.

clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
103

Creating a type alias might make this more readable & easier to refactor later.

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
102

Can you point out in a comment that this value is just temporary for context hash computation and will be replaced by real path later on?

clang/tools/clang-scan-deps/ClangScanDeps.cpp
403

Can you split this into separate patch?

This revision is now accepted and ready to land.Aug 16 2022, 10:29 AM
benlangmuir edited the summary of this revision. (Show Details)

Per review

  • Add typedef for callback type
  • Add comment about mapping paths to "-"
  • Update commit message for module cache path computation change
benlangmuir marked 2 inline comments as done.Aug 16 2022, 11:52 AM
benlangmuir added inline comments.
clang/tools/clang-scan-deps/ClangScanDeps.cpp
403

This is hard because we don't have the association between input command-line and module dependencies in the previous code. Per our offline discussion I've mentioned this in the commit message instead.