This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Use a cc1 invocation in FullDependencies::getCommandLine()
AbandonedPublic

Authored by benlangmuir on Aug 12 2022, 11:29 AM.

Details

Summary

Instead of trying to "fix" the original driver invocatin by appending
arguments to it, use a CompilerInvocation to give precise control over
the invocation, and serialize it to a -cc1 command.

This change should make it easier to (in the future) canonicalize the
command-line (e.g. to improve hits in something like ccache) or apply
optimizations, similar to what we do for module build commands.

Diff Detail

Event Timeline

benlangmuir created this revision.Aug 12 2022, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2022, 11:29 AM
benlangmuir requested review of this revision.Aug 12 2022, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2022, 11:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I like this direction, I've been wanting to do this for a long time.

Since the scanner accepts driver invocations that can expand into multiple (-cc1, assembler, linker, ...) invocations, we'll need to update the clang-scan-deps output JSON format to accommodate for that (as well as the downstream libclang API). You can use -save-temps, -fno-integrated-as and similar to test that. This will probably need some work around ToolInvocation::run() and getCC1Arguments().