@@ -51,11 +51,12 @@ extension IncrementalCompilationState {
5151
5252 public func compute( batchJobFormer: inout Driver ) throws -> FirstWave {
5353 return try blockingConcurrentAccessOrMutation {
54- let ( initiallySkippedCompileJobs, mandatoryJobsInOrder) =
54+ let ( initiallySkippedCompileJobs, mandatoryJobsInOrder, afterCompiles ) =
5555 try computeInputsAndGroups ( batchJobFormer: & batchJobFormer)
5656 return FirstWave (
5757 initiallySkippedCompileJobs: initiallySkippedCompileJobs,
58- mandatoryJobsInOrder: mandatoryJobsInOrder)
58+ mandatoryJobsInOrder: mandatoryJobsInOrder,
59+ jobsAfterCompiles: afterCompiles)
5960 }
6061 }
6162 }
@@ -74,34 +75,39 @@ extension IncrementalCompilationState.FirstWaveComputer {
7475 /// listed in fingerprintExternalDependencies.
7576 private func computeInputsAndGroups( batchJobFormer: inout Driver )
7677 throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
77- mandatoryJobsInOrder: [ Job ] )
78+ mandatoryJobsInOrder: [ Job ] ,
79+ jobsAfterCompiles: [ Job ] )
7880 {
7981 let compileJobs =
8082 Dictionary ( uniqueKeysWithValues:
8183 jobsInPhases. compileJobs. map { ( $0. primaryInputs [ 0 ] , $0) } )
8284 let buildRecord = self . moduleDependencyGraph. buildRecord
83- let jobCreatingPch = jobsInPhases. beforeCompiles. first ( where: { $0. kind == . generatePCH} )
84- guard !buildRecord. inputInfos. isEmpty else {
85- func everythingIsMandatory( )
86- throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
87- mandatoryJobsInOrder: [ Job ] )
88- {
89- let mandatoryCompileJobsInOrder = self . inputFiles. swiftSourceFiles. compactMap {
90- input -> Job ? in
91- compileJobs [ input. typedFile]
92- }
85+ let jobCreatingPch = jobsInPhases. beforeCompiles. first { $0. kind == . generatePCH }
86+
87+ func everythingIsMandatory( )
88+ throws -> ( initiallySkippedCompileJobs: [ TypedVirtualPath : Job ] ,
89+ mandatoryJobsInOrder: [ Job ] ,
90+ jobsAfterCompiles: [ Job ] )
91+ {
92+ let mandatoryCompileJobsInOrder = self . inputFiles. swiftSourceFiles. compactMap {
93+ input -> Job ? in
94+ compileJobs [ input. typedFile]
95+ }
9396
94- let mandatoryJobsInOrder = try
95- jobsInPhases. beforeCompiles +
96- batchJobFormer. formBatchedJobs (
97- mandatoryCompileJobsInOrder,
98- showJobLifecycle: showJobLifecycle,
99- jobCreatingPch: jobCreatingPch)
97+ let mandatoryJobsInOrder = try
98+ jobsInPhases. beforeCompiles +
99+ batchJobFormer. formBatchedJobs (
100+ mandatoryCompileJobsInOrder,
101+ showJobLifecycle: showJobLifecycle,
102+ jobCreatingPch: jobCreatingPch)
103+
104+ moduleDependencyGraph. setPhase ( to: . buildingAfterEachCompilation)
105+ return ( initiallySkippedCompileJobs: [ : ] ,
106+ mandatoryJobsInOrder: mandatoryJobsInOrder,
107+ jobsAfterCompiles: jobsInPhases. afterCompiles)
108+ }
100109
101- moduleDependencyGraph. setPhase ( to: . buildingAfterEachCompilation)
102- return ( initiallySkippedCompileJobs: [ : ] ,
103- mandatoryJobsInOrder: mandatoryJobsInOrder)
104- }
110+ guard !buildRecord. inputInfos. isEmpty else {
105111 return try everythingIsMandatory ( )
106112 }
107113 moduleDependencyGraph. setPhase ( to: . updatingAfterCompilation)
@@ -115,9 +121,7 @@ extension IncrementalCompilationState.FirstWaveComputer {
115121
116122 let mandatoryCompileJobsInOrder = inputFiles. compactMap {
117123 input -> Job ? in
118- initiallySkippedInputs. contains ( input)
119- ? nil
120- : compileJobs [ input]
124+ return initiallySkippedInputs. contains ( input) ? nil : compileJobs [ input]
121125 }
122126
123127 let batchedCompilationJobs = try batchJobFormer. formBatchedJobs (
@@ -129,9 +133,16 @@ extension IncrementalCompilationState.FirstWaveComputer {
129133 // we can skip running `beforeCompiles` jobs if we also ensure that none of the `afterCompiles` jobs
130134 // have any dependencies on them.
131135 let skipAllJobs = batchedCompilationJobs. isEmpty ? !nonVerifyAfterCompileJobsDependOnBeforeCompileJobs( ) : false
132- let mandatoryJobsInOrder = skipAllJobs ? [ ] : jobsInPhases. beforeCompiles + batchedCompilationJobs
136+
137+ // Schedule emitModule job together with verify module interface job.
138+ let beforeCompileJobs = skipAllJobs ? [ ] : jobsInPhases. beforeCompiles
139+ let afterCompileJobs = jobsInPhases. afterCompiles. compactMap { job in
140+ skipAllJobs && job. kind == . verifyModuleInterface ? nil : job
141+ }
142+ let mandatoryJobsInOrder = beforeCompileJobs + batchedCompilationJobs
133143 return ( initiallySkippedCompileJobs: initiallySkippedCompileJobs,
134- mandatoryJobsInOrder: mandatoryJobsInOrder)
144+ mandatoryJobsInOrder: mandatoryJobsInOrder,
145+ jobsAfterCompiles: afterCompileJobs)
135146 }
136147
137148 /// Determine if any of the jobs in the `afterCompiles` group depend on outputs produced by jobs in
0 commit comments