Skip to content

Commit 4ba8012

Browse files
authored
Merge pull request #79919 from qiongsiwu/eng_145860213
[Dependency Scanning] Setting Default Clang Optimize Args Option to All llvm/llvm-project#129809 turned off current working directory (CWD) optimization for clang dependency scanning, because clang needs to coordinate with the build system to safely optimize the CWD. Swift can already handle the CWDs. This PR turns the CWD optimization on for Swift.
2 parents 0c62d1f + 81431cb commit 4ba8012

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/AST/ModuleDependencies.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ SwiftDependencyScanningService::SwiftDependencyScanningService() {
490490
clang::CASOptions(),
491491
/* CAS (llvm::cas::ObjectStore) */ nullptr,
492492
/* Cache (llvm::cas::ActionCache) */ nullptr,
493-
/* SharedFS */ nullptr);
493+
/* SharedFS */ nullptr,
494+
// ScanningOptimizations::Default excludes the current working
495+
// directory optimization. Clang needs to communicate with
496+
// the build system to handle the optimization safely.
497+
// Swift can handle the working directory optimizaiton
498+
// already so it is safe to turn on all optimizations.
499+
clang::tooling::dependencies::ScanningOptimizations::All);
494500
SharedFilesystemCache.emplace();
495501
}
496502

@@ -748,7 +754,11 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
748754
ClangScanningFormat,
749755
Instance.getInvocation().getCASOptions().CASOpts,
750756
Instance.getSharedCASInstance(), Instance.getSharedCacheInstance(),
751-
UseClangIncludeTree ? nullptr : CacheFS);
757+
UseClangIncludeTree ? nullptr : CacheFS,
758+
// The current working directory optimization (off by default)
759+
// should not impact CAS. We set the optization to all to be
760+
// consistent with the non-CAS case.
761+
clang::tooling::dependencies::ScanningOptimizations::All);
752762

753763
return false;
754764
}

0 commit comments

Comments
 (0)