@@ -261,6 +261,7 @@ class swift::ParseableInterfaceBuilder {
261261 const StringRef moduleCachePath;
262262 const StringRef prebuiltCachePath;
263263 const bool serializeDependencyHashes;
264+ const bool trackSystemDependencies;
264265 const SourceLoc diagnosticLoc;
265266 DependencyTracker *const dependencyTracker;
266267 CompilerInvocation subInvocation;
@@ -295,6 +296,7 @@ class swift::ParseableInterfaceBuilder {
295296 subInvocation.setClangModuleCachePath (moduleCachePath);
296297 subInvocation.getFrontendOptions ().PrebuiltModuleCachePath =
297298 prebuiltCachePath;
299+ subInvocation.getFrontendOptions ().TrackSystemDeps = trackSystemDependencies;
298300
299301 // Respect the detailed-record preprocessor setting of the parent context.
300302 // This, and the "raw" clang module format it implicitly enables, are
@@ -449,12 +451,14 @@ class swift::ParseableInterfaceBuilder {
449451 StringRef moduleCachePath,
450452 StringRef prebuiltCachePath,
451453 bool serializeDependencyHashes = false ,
454+ bool trackSystemDependencies = false ,
452455 SourceLoc diagnosticLoc = SourceLoc(),
453456 DependencyTracker *tracker = nullptr )
454457 : ctx(ctx), fs(*ctx.SourceMgr.getFileSystem()), diags(ctx.Diags),
455458 interfacePath (interfacePath), moduleName(moduleName),
456459 moduleCachePath(moduleCachePath), prebuiltCachePath(prebuiltCachePath),
457460 serializeDependencyHashes(serializeDependencyHashes),
461+ trackSystemDependencies(trackSystemDependencies),
458462 diagnosticLoc(diagnosticLoc), dependencyTracker(tracker) {
459463 configureSubInvocation ();
460464 }
@@ -532,7 +536,8 @@ class swift::ParseableInterfaceBuilder {
532536 ForwardingDiagnosticConsumer FDC (diags);
533537 SubInstance.addDiagnosticConsumer (&FDC);
534538
535- SubInstance.createDependencyTracker (/* TrackSystemDeps=*/ true );
539+ SubInstance.createDependencyTracker (FEOpts.TrackSystemDeps );
540+
536541 if (SubInstance.setup (subInvocation)) {
537542 SubError = true ;
538543 return ;
@@ -656,6 +661,10 @@ class ParseableInterfaceModuleLoaderImpl {
656661 // it.
657662 H = hash_combine (H, SubInvocation.getSDKPath ());
658663
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+
659668 return llvm::APInt (64 , H).toString (36 , /* Signed=*/ false );
660669 }
661670
@@ -928,12 +937,21 @@ class ParseableInterfaceModuleLoaderImpl {
928937 // / loading strategy.
929938 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
930939 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+ }
931948
932949 // Set up a builder if we need to build the module. It'll also set up
933950 // the subinvocation we'll need to use to compute the cache paths.
934951 ParseableInterfaceBuilder builder (
935952 ctx, interfacePath, moduleName, cacheDir, prebuiltCacheDir,
936- /* serializeDependencyHashes*/ false , diagnosticLoc, dependencyTracker);
953+ /* serializeDependencyHashes*/ false , trackSystemDependencies,
954+ diagnosticLoc, dependencyTracker);
937955 auto &subInvocation = builder.getSubInvocation ();
938956
939957 // Compute the output path if we're loading or emitting a cached module.
@@ -1036,7 +1054,7 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
10361054bool ParseableInterfaceModuleLoader::buildSwiftModuleFromSwiftInterface (
10371055 ASTContext &Ctx, StringRef CacheDir, StringRef PrebuiltCacheDir,
10381056 StringRef ModuleName, StringRef InPath, StringRef OutPath,
1039- bool SerializeDependencyHashes) {
1057+ bool SerializeDependencyHashes, bool TrackSystemDependencies ) {
10401058 ParseableInterfaceBuilder builder (Ctx, InPath, ModuleName,
10411059 CacheDir, PrebuiltCacheDir,
10421060 SerializeDependencyHashes);
0 commit comments