 
 extension Driver {
 
+  fileprivate mutating func generateABICheckJob(_ moduleName: String,
+                                                _ baselineABIDir: AbsolutePath,
+                                                _ currentABI: TypedVirtualPath) throws -> Job? {
+    let baselineABI = TypedVirtualPath(file: VirtualPath.absolute(baselineABIDir
+      .appending(component: "\(moduleName).swiftmodule")
+      .appending(component: currentABI.file.basename)).intern(), type: .jsonABIBaseline)
+    guard try localFileSystem.exists(baselineABI.file) else {
+      return nil
+    }
+    var commandLine: [Job.ArgTemplate] = []
+    commandLine.appendFlag(.diagnoseSdk)
+    commandLine.appendFlag(.inputPaths)
+    commandLine.appendPath(baselineABI.file)
+    commandLine.appendFlag(.inputPaths)
+    commandLine.appendPath(currentABI.file)
+    commandLine.appendFlag(.compilerStyleDiags)
+    commandLine.appendFlag(.abi)
+    commandLine.appendFlag(.swiftOnly)
+    commandLine.appendFlag(.printModule)
+    return Job(
+      moduleName: moduleName,
+      kind: .compareABIBaseline,
+      tool: .absolute(try toolchain.getToolPath(.swiftAPIDigester)),
+      commandLine: commandLine,
+      inputs: [currentABI, baselineABI],
+      primaryInputs: [],
+      outputs: []
+    )
+  }
+
   private mutating func generateSingleModuleBuildingJob(_ moduleName: String,  _ prebuiltModuleDir: AbsolutePath,
                                                         _ inputPath: PrebuiltModuleInput, _ outputPath: PrebuiltModuleOutput,
-                                                        _ dependencies: [TypedVirtualPath], _ abiDumpDir: AbsolutePath?) throws -> Job {
+                                                        _ dependencies: [TypedVirtualPath], _ abiDumpDir: AbsolutePath?,
+                                                        _ abiBaselineDir: AbsolutePath?) throws -> [Job] {
     assert(inputPath.path.file.basenameWithoutExt == outputPath.path.file.basenameWithoutExt)
     var commandLine: [Job.ArgTemplate] = []
     commandLine.appendFlag(.compileModuleFromInterface)

      let abiPath = TypedVirtualPath(file: abiFilePath, type: .jsonABIBaseline)
      commandLine.appendPath(abiPath.file)
      allOutputs.append(abiPath)
    }
    return Job(
      moduleName: moduleName,
      kind: .compile,
      tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),

        let module = openModules[idx]
        let dependencies = getSwiftDependencies(for: module)
        try forEachInputOutputPair(module) { input, output in
          jobs.append(contentsOf: try generateSingleModuleBuildingJob(module,
            prebuiltModuleDir, input, output,
            try getOutputPaths(withName: dependencies, loadableFor: input.arch), abiDumpDir, abiBaselineDir))
        }
        // For each dependency, add to the list to handle if the list doesn't
        // contain this dependency.
