This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Return the whole TU command line
ClosedPublic

Authored by jansvoboda11 on Feb 4 2022, 4:35 AM.

Details

Summary

The dependency scanner already generates canonical -cc1 command lines that can be used to compile discovered modular dependencies.

For translation unit command lines, the scanner only generates additional driver arguments the build system is expected to append to the original command line.

While this works most of the time, there are situations where that's not the case. For example with -Wunused-command-line-argument, Clang will complain about the -fmodules-cache-path= argument that's not being used in explicit modular builds. Combine that with -Werror and the build outright fails.

To prevent such failures, this patch changes the dependency scanner to return the full driver command line to compile the original translation unit. This gives us more opportunities to massage the arguments into something reasonable.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.Feb 4 2022, 4:35 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 4:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 edited the summary of this revision. (Show Details)Feb 4 2022, 4:43 AM

Undo one test change.

jansvoboda11 added inline comments.Feb 4 2022, 4:48 AM
clang/test/ClangScanDeps/modules-inferred-explicit-build.m
15

This patch will make it possible to strip out -fmodules-cache-path=, allowing us to remove -Wno-unused-command-line-argument in this test. Note that previously, we needed to strip the argument ourselves manually to get the same effect.

Bigcheese accepted this revision.Feb 11 2022, 3:33 PM

This does require build systems to be able to totally replace a command line rather than just add to it, but it seems like that's a requirement unless we add a way to modify the command line to Clang. lgtm.

This revision is now accepted and ready to land.Feb 11 2022, 3:33 PM
This revision was landed with ongoing or failed builds.Feb 23 2022, 6:46 AM
This revision was automatically updated to reflect the committed changes.