Skip to content

Commit fae00bc

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 9861561 commit fae00bc

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
@@ -3467,6 +3467,22 @@ final class SwiftDriverTests: XCTestCase {
34673467
XCTAssertEqual(plannedJobs.count, 4)
34683468
XCTAssertEqual(Set(plannedJobs.map { $0.kind }), Set([.compile, .emitModule, .link]))
34693469
}
3470+
3471+
do {
3472+
// Schedule an emit-module separately job even if there are non-compilable inputs.
3473+
var driver = try Driver(args: ["swiftc", "foo.swift", "bar.dylib", "-emit-library", "foo.dylib", "-emit-module-path", "foo.swiftmodule"],
3474+
env: envVars)
3475+
let plannedJobs = try driver.planBuild()
3476+
XCTAssertEqual(plannedJobs.count, 3)
3477+
XCTAssertEqual(Set(plannedJobs.map { $0.kind }), Set([.compile, .emitModule, .link]))
3478+
3479+
let emitJob = try plannedJobs.findJob(.emitModule)
3480+
XCTAssertTrue(emitJob.commandLine.contains(try toPathOption("foo.swift")))
3481+
XCTAssertFalse(emitJob.commandLine.contains(try toPathOption("bar.dylib")))
3482+
3483+
let linkJob = try plannedJobs.findJob(.link)
3484+
XCTAssertTrue(linkJob.commandLine.contains(try toPathOption("bar.dylib")))
3485+
}
34703486
}
34713487

34723488
func testEmitModuleSeparatelyWMO() throws {

0 commit comments

Comments
 (0)