Skip to content

Commit b5eba93

Browse files
authored
Merge pull request #461 from CodaFi/a-distinction-without-a-difference
Fold Incremental External Dependency Nodes Into External Dependency Nodes
2 parents 7d470c5 + b9541c9 commit b5eba93

File tree

6 files changed

+14
-46
lines changed

6 files changed

+14
-46
lines changed

Sources/SwiftDriver/IncrementalCompilation/DependencyKey.swift

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,14 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
139139
/// The `context` field corresponds to the mangled name of the type. The
140140
/// `name` field corresponds to the *unmangled* name of the member.
141141
case member(context: String, name: String)
142-
/// A dependency that resides outside of the module being built, but which
143-
/// has integrated dependency information in a format the driver
144-
/// understands.
145-
///
146-
/// These dependencies correspond to Swift modules that were built with
147-
/// `-enable-experimental-cross-module-incremental-build`. These modules
148-
/// contain a special section with swiftdeps information for the module
149-
/// in it.
150-
///
151-
/// The full path to the external dependency as seen by the frontend is
152-
/// available from this node.
153-
case incrementalExternalDependency(ExternalDependency)
154142

155-
var externalDependency: (ExternalDependency, isIncremental: Bool)? {
143+
var externalDependency: ExternalDependency? {
156144
switch self {
157145
case let .externalDepend(externalDependency):
158-
return (externalDependency, isIncremental: false)
159-
case let .incrementalExternalDependency(externalDependency):
160-
return (externalDependency, isIncremental: true)
146+
return externalDependency
161147
default:
162-
return nil}
148+
return nil
149+
}
163150
}
164151

165152
public var description: String {
@@ -178,8 +165,6 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
178165
return "module '\(externalDependency)'"
179166
case let .sourceFileProvide(name: name):
180167
return "source file \((try? VirtualPath(path: name).basename) ?? name)"
181-
case let .incrementalExternalDependency(externalDependency):
182-
return "incremental module '\(externalDependency)'"
183168
}
184169
}
185170
}

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraph.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,17 @@ extension ModuleDependencyGraph {
299299
isIncremental: Bool
300300
) -> [ModuleDependencyGraph.Node] {
301301
// These nodes will depend on the *interface* of the external Decl.
302-
let key = DependencyKey(interfaceFor: externalSwiftDeps, isIncremental: isIncremental)
302+
let key = DependencyKey(interfaceFor: externalSwiftDeps)
303303
let node = Node(key: key, fingerprint: nil, dependencySource: nil)
304304
return nodeFinder
305305
.orderedUses(of: node)
306306
.filter({ use in isUntraced(use) })
307307
}
308308
}
309309
fileprivate extension DependencyKey {
310-
init(interfaceFor dep: ExternalDependency, isIncremental: Bool) {
310+
init(interfaceFor dep: ExternalDependency) {
311311
self.init(aspect: .interface,
312-
designator: isIncremental
313-
? .incrementalExternalDependency(dep)
314-
: .externalDepend(dep))
312+
designator: .externalDepend(dep))
315313
}
316314
}
317315
// MARK: - tracking traced nodes
@@ -938,9 +936,6 @@ fileprivate extension DependencyKey.Designator {
938936
case 6:
939937
try mustBeEmpty(context)
940938
self = .sourceFileProvide(name: name)
941-
case 7:
942-
try mustBeEmpty(context)
943-
self = .incrementalExternalDependency(ExternalDependency(name))
944939
default: throw ModuleDependencyGraph.ReadError.unknownKind
945940
}
946941
}
@@ -961,8 +956,6 @@ fileprivate extension DependencyKey.Designator {
961956
return 5
962957
case .sourceFileProvide(name: _):
963958
return 6
964-
case .incrementalExternalDependency(_):
965-
return 7
966959
}
967960
}
968961

@@ -976,8 +969,6 @@ fileprivate extension DependencyKey.Designator {
976969
return nil
977970
case .sourceFileProvide(name: _):
978971
return nil
979-
case .incrementalExternalDependency(_):
980-
return nil
981972
case .nominal(context: let context):
982973
return context
983974
case .potentialMember(context: let context):
@@ -997,8 +988,6 @@ fileprivate extension DependencyKey.Designator {
997988
return path.fileName
998989
case .sourceFileProvide(name: let name):
999990
return name
1000-
case .incrementalExternalDependency(let path):
1001-
return path.fileName
1002991
case .member(context: _, name: let name):
1003992
return name
1004993
case .nominal(context: _):

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,10 @@ extension ModuleDependencyGraph.Integrator {
208208
let isNewUse = destination.nodeFinder.record(def: def.key,
209209
use: moduleUseNode)
210210
guard isNewUse else { return }
211-
guard let (externalDependency, isIncremental: isIncremental) =
212-
def.key.designator.externalDependency
213-
else {
211+
guard let externalDependency = def.key.designator.externalDependency else {
214212
return
215213
}
214+
let isIncremental = def.fingerprint != nil
216215
let isKnown = (isIncremental
217216
? destination.incrementalExternalDependencies
218217
: destination.externalDependencies)

Sources/SwiftDriver/IncrementalCompilation/SourceFileDependencyGraph.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ fileprivate extension DependencyKey.Designator {
308308
case 6:
309309
try mustBeEmpty(context)
310310
self = .sourceFileProvide(name: name)
311-
case 7:
312-
try mustBeEmpty(context)
313-
self = .incrementalExternalDependency(ExternalDependency(name))
314311
default: throw SourceFileDependencyGraph.ReadError.unknownKind
315312
}
316313
}

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ class CrossModuleIncrementalBuildTests: XCTestCase {
732732
}
733733

734734
func testEmbeddedModuleDependencies() throws {
735+
throw XCTSkip("Requires new frontend work to remove incremental external dependencies distinction.")
736+
/*
735737
try withTemporaryDirectory { path in
736738
try localFileSystem.changeCurrentWorkingDirectory(to: path)
737739
do {
@@ -796,7 +798,7 @@ class CrossModuleIncrementalBuildTests: XCTestCase {
796798
var foundNode = false
797799
let swiftmodulePath = ExternalDependency(path.appending(component: "MagicKit.swiftmodule").pathString)
798800
graph.forEachNode { node in
799-
if case .incrementalExternalDependency(context: swiftmodulePath) = node.key.designator {
801+
if case .externalDepend(swiftmodulePath) = node.key.designator {
800802
XCTAssertFalse(foundNode)
801803
foundNode = true
802804
XCTAssertEqual(node.key.aspect, .interface)
@@ -805,6 +807,6 @@ class CrossModuleIncrementalBuildTests: XCTestCase {
805807
}
806808
}
807809
XCTAssertTrue(foundNode)
808-
}
810+
}*/
809811
}
810812
}

Tests/SwiftDriverTests/ModuleDependencyGraphTests.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,12 +863,11 @@ enum MockDependencyKind {
863863
case nominal
864864
case potentialMember
865865
case member
866-
case incrementalExternalDependency
867866

868867
var singleNameIsContext: Bool? {
869868
switch self {
870869
case .nominal, .potentialMember: return true
871-
case .topLevel, .dynamicLookup, .externalDepend, .incrementalExternalDependency, .sourceFileProvide: return false
870+
case .topLevel, .dynamicLookup, .externalDepend, .sourceFileProvide: return false
872871
case .member: return nil
873872
}
874873
}
@@ -1363,9 +1362,6 @@ fileprivate extension DependencyKey.Designator {
13631362
case .externalDepend:
13641363
mustBeAbsent(context)
13651364
self = .externalDepend(ExternalDependency(name!))
1366-
case .incrementalExternalDependency:
1367-
mustBeAbsent(context)
1368-
self = .incrementalExternalDependency(ExternalDependency(name!))
13691365
case .sourceFileProvide:
13701366
mustBeAbsent(context)
13711367
self = .sourceFileProvide(name: name!)

0 commit comments

Comments
 (0)