This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] Track affecting modules
ClosedPublic

Authored by jansvoboda11 on Aug 22 2022, 7:03 PM.

Details

Summary

When compiling a module, its semantics and Clang's behavior are affected by other modules. These modules are typically the imported ones. However, during implicit build, some modules end up being compiled and read without being actually imported. This patch starts tracking such modules and serializing them into .pcm files. This enables the dependency scanner to construct explicit compilations that mimic implicit build.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Aug 22 2022, 7:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 7:03 PM
jansvoboda11 requested review of this revision.Aug 22 2022, 7:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 7:03 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 edited the summary of this revision. (Show Details)Aug 22 2022, 7:04 PM
benlangmuir added inline comments.Aug 23 2022, 8:36 AM
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
284

If using eager loading, this will cause us to load the module, right? Does that behaviour match the implicit build?

clang/test/ClangScanDeps/modules-incomplete-umbrella.c
83

The test should probably cover the imports in the command-lines.

jansvoboda11 added inline comments.Aug 23 2022, 2:29 PM
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
284

That's correct. The implicit build does the same.

clang/test/ClangScanDeps/modules-incomplete-umbrella.c
83

Most -fmodule-file= checks were removed in D132066, since these are likely to change in the future, and I'm okay with relying on "clang-module-deps". I can see the argument that in this particular case the dependencies are not ordinary imports, but somewhat of an edge case, so I'm fine with adding the checks.

benlangmuir added inline comments.Aug 23 2022, 2:42 PM
clang/test/ClangScanDeps/modules-incomplete-umbrella.c
83

I'd prefer to add the checks in this specific case. I agree it's not relevant to most other tests.

Add -fmodule-file= assertions

jansvoboda11 marked 2 inline comments as done.Aug 23 2022, 2:59 PM
benlangmuir accepted this revision.Aug 23 2022, 3:00 PM
This revision is now accepted and ready to land.Aug 23 2022, 3:00 PM

Backslashes in tests on Windows

This revision was landed with ongoing or failed builds.Aug 24 2022, 11:10 AM
This revision was automatically updated to reflect the committed changes.