Skip to content

Commit 2a1f5e8

Browse files
committed
Pass-down -empty-abi-descriptor if evolution is disabled
We should also be able to emit ABI descriptor for modules without evolution. However, doing so leads us to deserialize more contents from binary modules, exposing more deserialization issues as a result.
1 parent 69050f1 commit 2a1f5e8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ extension Driver {
215215
commandLine.appendFlag("-internalize-at-link")
216216
}
217217

218+
// ABI descriptors are mostly for modules with -enable-library-evolution.
219+
// We should also be able to emit ABI descriptor for modules without evolution.
220+
// However, doing so leads us to deserialize more contents from binary modules,
221+
// exposing more deserialization issues as a result.
222+
if !parsedOptions.hasArgument(.enableLibraryEvolution) &&
223+
isFrontendArgSupported(.emptyAbiDescriptor) {
224+
commandLine.appendFlag(.emptyAbiDescriptor)
225+
}
226+
218227
// Pass down -user-module-version if we are working with a compiler that
219228
// supports it.
220229
if let ver = parsedOptions.getLastArgument(.userModuleVersion)?.asSingle,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,20 @@ final class SwiftDriverTests: XCTestCase {
566566
}
567567
}
568568

569+
func testABIDescriptorOnlyWhenEnableEvolution() throws {
570+
let flagName = "-empty-abi-descriptor"
571+
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift") { driver in
572+
let jobs = try driver.planBuild()
573+
let command = jobs[0].commandLine
574+
XCTAssertTrue(command.contains(.flag(flagName)))
575+
}
576+
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-enable-library-evolution") { driver in
577+
let jobs = try driver.planBuild()
578+
let command = jobs[0].commandLine
579+
XCTAssertFalse(command.contains(.flag(flagName)))
580+
}
581+
}
582+
569583
func testModuleSettings() throws {
570584
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift") { driver in
571585
XCTAssertNil(driver.moduleOutputInfo.output)

0 commit comments

Comments
 (0)