@@ -261,6 +261,7 @@ class swift::ParseableInterfaceBuilder {
261
261
const StringRef moduleCachePath;
262
262
const StringRef prebuiltCachePath;
263
263
const bool serializeDependencyHashes;
264
+ const bool trackSystemDependencies;
264
265
const SourceLoc diagnosticLoc;
265
266
DependencyTracker *const dependencyTracker;
266
267
CompilerInvocation subInvocation;
@@ -295,6 +296,7 @@ class swift::ParseableInterfaceBuilder {
295
296
subInvocation.setClangModuleCachePath (moduleCachePath);
296
297
subInvocation.getFrontendOptions ().PrebuiltModuleCachePath =
297
298
prebuiltCachePath;
299
+ subInvocation.getFrontendOptions ().TrackSystemDeps = trackSystemDependencies;
298
300
299
301
// Respect the detailed-record preprocessor setting of the parent context.
300
302
// This, and the "raw" clang module format it implicitly enables, are
@@ -449,12 +451,14 @@ class swift::ParseableInterfaceBuilder {
449
451
StringRef moduleCachePath,
450
452
StringRef prebuiltCachePath,
451
453
bool serializeDependencyHashes = false ,
454
+ bool trackSystemDependencies = false ,
452
455
SourceLoc diagnosticLoc = SourceLoc(),
453
456
DependencyTracker *tracker = nullptr )
454
457
: ctx(ctx), fs(*ctx.SourceMgr.getFileSystem()), diags(ctx.Diags),
455
458
interfacePath (interfacePath), moduleName(moduleName),
456
459
moduleCachePath(moduleCachePath), prebuiltCachePath(prebuiltCachePath),
457
460
serializeDependencyHashes(serializeDependencyHashes),
461
+ trackSystemDependencies(trackSystemDependencies),
458
462
diagnosticLoc(diagnosticLoc), dependencyTracker(tracker) {
459
463
configureSubInvocation ();
460
464
}
@@ -532,7 +536,8 @@ class swift::ParseableInterfaceBuilder {
532
536
ForwardingDiagnosticConsumer FDC (diags);
533
537
SubInstance.addDiagnosticConsumer (&FDC);
534
538
535
- SubInstance.createDependencyTracker (/* TrackSystemDeps=*/ true );
539
+ SubInstance.createDependencyTracker (FEOpts.TrackSystemDeps );
540
+
536
541
if (SubInstance.setup (subInvocation)) {
537
542
SubError = true ;
538
543
return ;
@@ -656,6 +661,10 @@ class ParseableInterfaceModuleLoaderImpl {
656
661
// it.
657
662
H = hash_combine (H, SubInvocation.getSDKPath ());
658
663
664
+ // Whether or not we're tracking system dependencies affects the
665
+ // invalidation behavior of this cache item.
666
+ H = hash_combine (H, SubInvocation.getFrontendOptions ().TrackSystemDeps );
667
+
659
668
return llvm::APInt (64 , H).toString (36 , /* Signed=*/ false );
660
669
}
661
670
@@ -928,12 +937,21 @@ class ParseableInterfaceModuleLoaderImpl {
928
937
// / loading strategy.
929
938
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
930
939
findOrBuildLoadableModule () {
940
+ // Track system dependencies if the parent tracker is set to do so.
941
+ // FIXME: This means -track-system-dependencies isn't honored when the
942
+ // top-level invocation isn't tracking dependencies
943
+ bool trackSystemDependencies = false ;
944
+ if (dependencyTracker) {
945
+ auto ClangDependencyTracker = dependencyTracker->getClangCollector ();
946
+ trackSystemDependencies = ClangDependencyTracker->needSystemDependencies ();
947
+ }
931
948
932
949
// Set up a builder if we need to build the module. It'll also set up
933
950
// the subinvocation we'll need to use to compute the cache paths.
934
951
ParseableInterfaceBuilder builder (
935
952
ctx, interfacePath, moduleName, cacheDir, prebuiltCacheDir,
936
- /* serializeDependencyHashes*/ false , diagnosticLoc, dependencyTracker);
953
+ /* serializeDependencyHashes*/ false , trackSystemDependencies,
954
+ diagnosticLoc, dependencyTracker);
937
955
auto &subInvocation = builder.getSubInvocation ();
938
956
939
957
// Compute the output path if we're loading or emitting a cached module.
@@ -1036,7 +1054,7 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
1036
1054
bool ParseableInterfaceModuleLoader::buildSwiftModuleFromSwiftInterface (
1037
1055
ASTContext &Ctx, StringRef CacheDir, StringRef PrebuiltCacheDir,
1038
1056
StringRef ModuleName, StringRef InPath, StringRef OutPath,
1039
- bool SerializeDependencyHashes) {
1057
+ bool SerializeDependencyHashes, bool TrackSystemDependencies ) {
1040
1058
ParseableInterfaceBuilder builder (Ctx, InPath, ModuleName,
1041
1059
CacheDir, PrebuiltCacheDir,
1042
1060
SerializeDependencyHashes);
0 commit comments