[PATCH] D150319: [clang][deps] Always use -fmodules-validate-once-per-build-session
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 10 15:23:30 PDT 2023
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The dependency scanner assumes immutable file system. In that context, we don't need to repeatedly validate PCM input files. This patch avoids that by using the existing `-fmodules-validate-once-per-build-session` mechanism.
Depends on D150318 <https://reviews.llvm.org/D150318>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150319
Files:
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -182,6 +182,12 @@
ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
+ ScanInstance.getHeaderSearchOpts().ModulesValidateOncePerBuildSession =
+ true;
+ // FIXME: Consider diagnosing when this overwrites existing timestamp.
+ ScanInstance.getHeaderSearchOpts().BuildSessionTimestamp =
+ Service.getBuildSessionTimestamp();
+
ScanInstance.setFileManager(FileMgr);
// Support for virtual file system overlays.
FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
@@ -9,15 +9,21 @@
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
#include "llvm/Support/TargetSelect.h"
+#include <chrono>
+
using namespace clang;
using namespace tooling;
using namespace dependencies;
DependencyScanningService::DependencyScanningService(
ScanningMode Mode, ScanningOutputFormat Format, bool OptimizeArgs,
- bool EagerLoadModules)
+ bool EagerLoadModules, uint64_t BuildSessionTimestamp)
: Mode(Mode), Format(Format), OptimizeArgs(OptimizeArgs),
- EagerLoadModules(EagerLoadModules) {
+ EagerLoadModules(EagerLoadModules),
+ BuildSessionTimestamp(
+ BuildSessionTimestamp != 0
+ ? BuildSessionTimestamp
+ : std::chrono::system_clock::now().time_since_epoch().count()) {
// Initialize targets for object file support.
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
===================================================================
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -50,7 +50,8 @@
public:
DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format,
bool OptimizeArgs = false,
- bool EagerLoadModules = false);
+ bool EagerLoadModules = false,
+ uint64_t BuildSessionTimestamp = 0);
ScanningMode getMode() const { return Mode; }
@@ -60,6 +61,8 @@
bool shouldEagerLoadModules() const { return EagerLoadModules; }
+ uint64_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; }
+
DependencyScanningFilesystemSharedCache &getSharedCache() {
return SharedCache;
}
@@ -73,6 +76,8 @@
bool OptimizeArgs;
/// Whether to set up command-lines to load PCM files eagerly.
bool EagerLoadModules;
+ /// The build session timestamp.
+ uint64_t BuildSessionTimestamp;
/// The global file system cache.
DependencyScanningFilesystemSharedCache SharedCache;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150319.521122.patch
Type: text/x-patch
Size: 3338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230510/a7ededdd/attachment.bin>
More information about the cfe-commits
mailing list