From 420748d29ff91a3b0f155bf35c489cac04307e40 Mon Sep 17 00:00:00 2001 From: WeijunDeng Date: Fri, 26 Sep 2025 16:33:07 +0800 Subject: [PATCH] [Incremental Builds]skip startingPoint of changed .swiftmodule. This means that recompilation is only triggered when the fingerprint of a dependent interface changes. --- .../ModuleDependencyGraphParts/Tracer.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift b/Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift index 6bd8fc8f9..6ec4cd988 100644 --- a/Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift +++ b/Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift @@ -66,6 +66,22 @@ extension ModuleDependencyGraph.Tracer { private mutating func collectPreviouslyUntracedDependents() { for n in startingPoints { + if (n.key.aspect == .interface) { + if case .sourceFileProvide(name: _) = n.key.designator { + if case let .known(source) = n.definitionLocation { + if source.typedFile.type == .swiftModule { + // If a change in the fingerprint of an interface causes a change in the swiftmodule, + // but other swiftmodules that depend on this swiftmodule do not depend on this interface, + // then those other swiftmodules should not be recompiled. + // + // This means that recompilation is only triggered when the fingerprint of a dependent interface changes. + graph.info.reporter?.report("skipped startingPoint key: \(n.key.description(in: graph)) definitionLocation: \(n.definitionLocation)") + continue + } + } + } + } + graph.info.reporter?.report("startingPoint key: \(n.key.description(in: graph)) definitionLocation: \(n.definitionLocation)") collectNextPreviouslyUntracedDependent(of: n) } }