         addJob: addJob,
         addLinkerInputs: addLinkerInputs)
      }
-
-    let linkJob = try linkJobIfNeeded(linkerInputs:
-                                        linkerInputs)
-
-    let dsymAndVerifyInfoJobs = try computeDsymAndVerifyDebugInfoJobsIfNeeded(
-      link: linkJob,
-      targetTriple: targetTriple,
-      debugInfo: debugInfo)
-
-    return Array( [
-      jobs,
-       linkJob.map {[$0]} ?? [],
-      dsymAndVerifyInfoJobs
-    ] .joined()
-    )
+    try addLinkAndPostLinkJobs(linkerInputs: linkerInputs,
+                               debugInfo: debugInfo,
+                               addJob: addJob)
+    return jobs
   }
 
 

    }
  }

  private mutating func linkJobIfNeeded(linkerInputs: [TypedVirtualPath]) throws -> Job? {
    if linkerOutputType != nil && !linkerInputs.isEmpty {
      return try linkJob(inputs: linkerInputs)
    }
    return nil
  }

  private  func computeDsymAndVerifyDebugInfoJobsIfNeeded(
    link: Job?, targetTriple: Triple, debugInfo: DebugInfo
  ) throws -> [Job] {
    guard let linkJob = link, targetTriple.isDarwin, debugInfo.level != nil
    else {
      return []
    }
    let dsymJob = try generateDSYMJob(inputs: linkJob.outputs)
    if !debugInfo.shouldVerify { return [dsymJob] }
    let verifyJob = try verifyDebugInfoJob(inputs: dsymJob.outputs)
    return [dsymJob, verifyJob]
  }


  /// Prescan the source files to produce a module dependency graph and turn it into a set
  /// of jobs required to build all dependencies.

    var moduleInputs = [TypedVirtualPath]()
    var moduleInputsFromJobOutputs = [TypedVirtualPath]()

    // Passing in these functions instead of inout parameters clarifies that
    // the code is only adding to the collections in question.
    func addJob(_ j: Job) { jobs.append(j) }
    func addJobs(_ js: [Job]) { jobs.append(contentsOf: js) }
    func addLinkerInput(_ li: TypedVirtualPath) { linkerInputs.append(li) }
