mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CAS][DependencyScanning] Don't keep a shared state of common file deps
Unlike `swift-frontend -scan-dependencies` option, when dependency scanner is used as a library by swift driver, the SwiftScanningService is shared for multiple driver invocations. It can't keep states (like common file dependencies) that can change from one invocation to another. Instead, the clang/SDK file dependencies are computed from each driver invocations to avoid out-of-date information when scanning service is reused. The test case for a shared Service will be added to swift-driver repo since there is no tool to test it within swift compiler.
This commit is contained in:
@@ -394,11 +394,31 @@ SwiftDependencyScanningService::SwiftDependencyScanningService() {
|
||||
SharedFilesystemCache.emplace();
|
||||
}
|
||||
|
||||
void SwiftDependencyTracker::addCommonSearchPathDeps(
|
||||
const SearchPathOptions &Opts) {
|
||||
// Add SDKSetting file.
|
||||
SmallString<256> SDKSettingPath;
|
||||
llvm::sys::path::append(SDKSettingPath, Opts.getSDKPath(),
|
||||
"SDKSettings.json");
|
||||
FS->status(SDKSettingPath);
|
||||
|
||||
// Add Legacy layout file.
|
||||
const std::vector<std::string> AllSupportedArches = {
|
||||
"arm64", "arm64e", "x86_64", "i386",
|
||||
"armv7", "armv7s", "armv7k", "arm64_32"};
|
||||
|
||||
for (auto RuntimeLibPath : Opts.RuntimeLibraryPaths) {
|
||||
std::error_code EC;
|
||||
for (auto &Arch : AllSupportedArches) {
|
||||
SmallString<256> LayoutFile(RuntimeLibPath);
|
||||
llvm::sys::path::append(LayoutFile, "layout-" + Arch + ".yaml");
|
||||
FS->status(LayoutFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwiftDependencyTracker::startTracking() {
|
||||
FS->trackNewAccesses();
|
||||
|
||||
for (auto &file : Files)
|
||||
(void)FS->status(file);
|
||||
}
|
||||
|
||||
llvm::Expected<llvm::cas::ObjectProxy>
|
||||
@@ -459,11 +479,6 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch some dependency files from clang importer.
|
||||
auto clangImporter = static_cast<ClangImporter *>(
|
||||
Instance.getASTContext().getClangModuleLoader());
|
||||
clangImporter->addClangInvovcationDependencies(CommonDependencyFiles);
|
||||
|
||||
auto CachingFS =
|
||||
llvm::cas::createCachingOnDiskFileSystem(Instance.getObjectStore());
|
||||
if (!CachingFS) {
|
||||
|
||||
Reference in New Issue
Block a user