Skip to content

Commit f920d43

Browse files
committed
Schedule an emit-module-separately job even if an input is not compilable
The following invocation should schedule an emit-module-separately job for src.swift and include other.dylib in the link job. ``` swiftc -emit-library src.swift other.dylib ``` rdar://127238278
1 parent 6deb6fc commit f920d43

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ extension Driver {
136136
moduleOutputInfo: ModuleOutputInfo,
137137
inputFiles: [TypedVirtualPath]) -> Bool {
138138
if moduleOutputInfo.output == nil ||
139-
!inputFiles.allSatisfy({ $0.type.isPartOfSwiftCompilation }) {
139+
!inputFiles.contains(where: { $0.type.isPartOfSwiftCompilation }) {
140140
return false
141141
}
142142

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,6 +3504,22 @@ final class SwiftDriverTests: XCTestCase {
35043504
XCTAssertEqual(plannedJobs.count, 4)
35053505
XCTAssertEqual(Set(plannedJobs.map { $0.kind }), Set([.compile, .emitModule, .link]))
35063506
}
3507+
3508+
do {
3509+
// Schedule an emit-module separately job even if there are non-compilable inputs.
3510+
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.dylib", "-emit-library", "foo.dylib", "-emit-module-path", "foo.swiftmodule"],
3511+
env: envVars)
3512+
let plannedJobs = try driver.planBuild()
3513+
XCTAssertEqual(plannedJobs.count, 3)
3514+
XCTAssertEqual(Set(plannedJobs.map { $0.kind }), Set([.compile, .emitModule, .link]))
3515+
3516+
let emitJob = try plannedJobs.findJob(.emitModule)
3517+
XCTAssertTrue(emitJob.commandLine.contains(try toPathOption("foo.swift")))
3518+
XCTAssertFalse(emitJob.commandLine.contains(try toPathOption("bar.dylib")))
3519+
3520+
let linkJob = try plannedJobs.findJob(.link)
3521+
XCTAssertTrue(linkJob.commandLine.contains(try toPathOption("bar.dylib")))
3522+
}
35073523
}
35083524

35093525
func testEmitModuleSeparatelyWMO() throws {

0 commit comments

Comments
 (0)