Skip to content

Commit 0d4a095

Browse files
committed
PrebuiltModuleGen: dedupe module names before generating prebuilt modules.
We collect these Swift module names from the outputs of dependency scanning. However, we've noticed dupes in the output, leading to build system reporting fatal errors. As a fix, we dedupe the module names before generating prebuilt module cache. rdar://158615938
1 parent 69a7a93 commit 0d4a095

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,13 @@ extension Driver {
812812
return (key, outputPaths)
813813
})
814814

815-
func collectSwiftModuleNames(_ ids: [ModuleDependencyId]) -> [String] {
816-
return ids.compactMap { id in
815+
func collectUniqueSwiftModuleNames(_ ids: [ModuleDependencyId]) -> [String] {
816+
return Array(Set(ids.compactMap { id in
817817
if case .swift(let module) = id {
818818
return module
819819
}
820820
return nil
821-
}
821+
}))
822822
}
823823

824824
func getSwiftDependencies(for module: String) -> [String] {
@@ -827,7 +827,7 @@ extension Driver {
827827
guard !dependencies.isEmpty else {
828828
return []
829829
}
830-
return collectSwiftModuleNames(dependencies)
830+
return collectUniqueSwiftModuleNames(dependencies)
831831
}
832832

833833
func getOutputPaths(withName modules: [String], loadableFor arch: Triple.Arch) throws -> [TypedVirtualPath] {
@@ -870,7 +870,7 @@ extension Driver {
870870
// Keep track of modules we haven't handled.
871871
var unhandledModules = Set<String>(inputMap.keys)
872872
// Start from those modules explicitly imported into the file under scanning
873-
var openModules = collectSwiftModuleNames(dependencyGraph.mainModule.allDependencies)
873+
var openModules = collectUniqueSwiftModuleNames(dependencyGraph.mainModule.allDependencies)
874874
var idx = 0
875875
while idx != openModules.count {
876876
let module = openModules[idx]

0 commit comments

Comments
 (0)