This is an archive of the discontinued LLVM Phabricator instance.

[clang] Improve laziness of resolving module map headers.
ClosedPublic

Authored by adamcz on Feb 25 2022, 8:31 AM.

Details

Summary

clang has support for lazy headers in module maps - if size and/or
modtime and provided in the cppmap file, headers are only resolved when
an include directive for a file with that size/modtime is encoutered.

Before this change, the lazy resolution was all-or-nothing per module.
That means as soon as even one file in that module potentially matched
an include, all lazy files in that module were resolved. With this
change, only files with matching size/modtime will be resolved.

The goal is to avoid unnecessary stat() calls on non-included files,
which is especially valuable on networked file systems, with higher
latency.

Diff Detail

Event Timeline

adamcz requested review of this revision.Feb 25 2022, 8:31 AM
adamcz created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 8:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
kadircet accepted this revision.Feb 27 2022, 8:13 AM

Thanks, this LGTM. but I am afraid all users of modules/modulemaps might not be aware of the fact that a module might be "partially" resolved (or still unresolved after a resolve operation, ASTWriter is a good example of an aware user).

For example there's Module::isAvailable that checks MissingHeaders in a module for unavailability. I am not sure if it's possible to get there without ever fully resolving a Module, but I couldn't prove otherwise either.
So this might cause surprising breakages or hide some diagnostics.

It would be great if you could test the change against LLVM or some other codebases with module enabled builds to see nothing crashes. Also we should probably be on the watch out after landing this for possible complaints from outside.

This revision is now accepted and ready to land.Feb 27 2022, 8:13 AM
This revision was landed with ongoing or failed builds.Mar 1 2022, 7:02 AM
This revision was automatically updated to reflect the committed changes.