Skip to content

Commit 6d3a6da

Browse files
committed
Emit ABI descriptors in final module generation jobs
1 parent fef589a commit 6d3a6da

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ public struct Driver {
336336
/// A global queue for emitting non-interrupted messages into stderr
337337
public static let stdErrQueue = DispatchQueue(label: "org.swift.driver.emit-to-stderr")
338338

339+
enum KnownCompilerFeature: String {
340+
case emit_abi_descriptor = "emit-abi-descriptor"
341+
}
339342

340343
lazy var sdkPath: VirtualPath? = {
341344
guard let rawSdkPath = frontendTargetInfo.sdkPath?.path else {
@@ -367,6 +370,10 @@ public struct Driver {
367370
}
368371
}
369372

373+
func isFeatureSupported(_ feature: KnownCompilerFeature) -> Bool {
374+
return supportedFrontendFeatures.contains(feature.rawValue)
375+
}
376+
370377
/// Handler for emitting diagnostics to stderr.
371378
public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
372379
stdErrQueue.sync {

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ extension Driver {
8787
commandLine.appendFlag(.parseAsLibrary)
8888
}
8989

90+
let outputPath = VirtualPath.lookup(moduleOutputPath)
9091
commandLine.appendFlag(.o)
91-
commandLine.appendPath(VirtualPath.lookup(moduleOutputPath))
92-
92+
commandLine.appendPath(outputPath)
93+
if isFeatureSupported(.emit_abi_descriptor) {
94+
commandLine.appendFlag(.emitAbiDescriptorPath)
95+
commandLine.appendPath(outputPath.replacingExtension(with: .jsonABIBaseline))
96+
}
9397
return Job(
9498
moduleName: moduleOutputInfo.name,
9599
kind: .emitModule,

Sources/SwiftDriver/Jobs/MergeModuleJob.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ extension Driver {
7272
try commandLine.appendLast(.disableIncrementalImports, from: &parsedOptions)
7373
}
7474

75+
let outputPath = VirtualPath.lookup(moduleOutputInfo.output!.outputPath)
7576
commandLine.appendFlag(.o)
76-
commandLine.appendPath(VirtualPath.lookup(moduleOutputInfo.output!.outputPath))
77+
commandLine.appendPath(outputPath)
7778

79+
if isFeatureSupported(.emit_abi_descriptor) {
80+
commandLine.appendFlag(.emitAbiDescriptorPath)
81+
commandLine.appendPath(outputPath.replacingExtension(with: .jsonABIBaseline))
82+
}
7883
return Job(
7984
moduleName: moduleOutputInfo.name,
8085
kind: .mergeModule,

0 commit comments

Comments
 (0)