@@ -215,7 +215,7 @@ extension LLBuildManifestBuilder {
215
215
) throws {
216
216
// Use the integrated Swift driver to compute the set of frontend
217
217
// jobs needed to build this Swift target.
218
- var commandLine = target. emitCommandLine ( ) ;
218
+ var commandLine = target. emitCommandLine ( )
219
219
commandLine. append ( " -driver-use-frontend-path " )
220
220
commandLine. append ( buildParameters. toolchain. swiftCompiler. pathString)
221
221
// FIXME: At some point SwiftPM should provide its own executor for
@@ -312,11 +312,9 @@ extension LLBuildManifestBuilder {
312
312
}
313
313
let allPackageDependencies = try ! topologicalSort ( nodes, successors: { $0. dependencies } )
314
314
315
- // All modules discovered so far as a part of this package manifest.
316
- // This includes modules that correspond to the package's own targets, package dependency
317
- // targets, and modules that are discovered as dependencies of the above in individual
318
- // dependency scanning actions
319
- var discoveredModulesMap : SwiftDriver . ModuleInfoMap = [ : ]
315
+ // Instantiate the inter-module dependency oracle which will cache commonly-scanned
316
+ // modules across targets' Driver instances.
317
+ let dependencyOracle = InterModuleDependencyOracle ( )
320
318
321
319
// Create commands for all target descriptions in the plan.
322
320
for dependency in allPackageDependencies. reversed ( ) {
@@ -344,7 +342,7 @@ extension LLBuildManifestBuilder {
344
342
switch description {
345
343
case . swift( let desc) :
346
344
try createExplicitSwiftTargetCompileCommand ( description: desc,
347
- discoveredModulesMap : & discoveredModulesMap )
345
+ dependencyOracle : dependencyOracle )
348
346
case . clang( let desc) :
349
347
createClangCompileCommand ( desc)
350
348
}
@@ -353,7 +351,7 @@ extension LLBuildManifestBuilder {
353
351
354
352
private func createExplicitSwiftTargetCompileCommand(
355
353
description: SwiftTargetBuildDescription ,
356
- discoveredModulesMap : inout SwiftDriver . ModuleInfoMap
354
+ dependencyOracle : InterModuleDependencyOracle
357
355
) throws {
358
356
// Inputs.
359
357
let inputs = computeSwiftCompileCmdInputs ( description)
@@ -365,7 +363,7 @@ extension LLBuildManifestBuilder {
365
363
366
364
// Commands.
367
365
try addExplicitBuildSwiftCmds ( description, inputs: inputs,
368
- discoveredModulesMap : & discoveredModulesMap )
366
+ dependencyOracle : dependencyOracle )
369
367
370
368
addTargetCmd ( description, cmdOutputs: cmdOutputs)
371
369
addModuleWrapCmd ( description)
@@ -374,7 +372,7 @@ extension LLBuildManifestBuilder {
374
372
private func addExplicitBuildSwiftCmds(
375
373
_ targetDescription: SwiftTargetBuildDescription ,
376
374
inputs: [ Node ] ,
377
- discoveredModulesMap : inout SwiftDriver . ModuleInfoMap
375
+ dependencyOracle : InterModuleDependencyOracle
378
376
) throws {
379
377
// Pass the driver its external dependencies (target dependencies)
380
378
var dependencyModulePathMap : SwiftDriver . ExternalTargetModulePathMap = [ : ]
@@ -384,7 +382,7 @@ extension LLBuildManifestBuilder {
384
382
385
383
// Compute the set of frontend
386
384
// jobs needed to build this Swift target.
387
- var commandLine = targetDescription. emitCommandLine ( ) ;
385
+ var commandLine = targetDescription. emitCommandLine ( )
388
386
commandLine. append ( " -driver-use-frontend-path " )
389
387
commandLine. append ( buildParameters. toolchain. swiftCompiler. pathString)
390
388
commandLine. append ( " -experimental-explicit-module-build " )
@@ -394,18 +392,10 @@ extension LLBuildManifestBuilder {
394
392
env: ProcessEnv . vars)
395
393
var driver = try Driver ( args: commandLine, fileSystem: targetDescription. fs,
396
394
executor: executor,
397
- externalBuildArtifacts : ( dependencyModulePathMap, discoveredModulesMap ) )
398
-
395
+ externalTargetModulePathMap : dependencyModulePathMap,
396
+ interModuleDependencyOracle : dependencyOracle )
399
397
let jobs = try driver. planBuild ( )
400
398
401
- // Save the path to the target's module to be used by its dependents
402
- // Save the dependency graph of this target to be used by its dependents
403
- guard let dependencyGraph = driver. interModuleDependencyGraph else {
404
- fatalError ( " Expected module dependency graph for target: \( targetDescription) " )
405
- }
406
- try InterModuleDependencyGraph . mergeModules ( from: dependencyGraph,
407
- into: & discoveredModulesMap)
408
-
409
399
try addSwiftDriverJobs ( for: targetDescription, jobs: jobs, inputs: inputs, resolver: resolver,
410
400
isMainModule: { driver. isExplicitMainModuleJob ( job: $0) } )
411
401
}
0 commit comments