Skip to content

Commit 20926ef

Browse files
authored
Merge pull request #1588 from xymus/ems-dylibs
Schedule an emit-module-separately job even if an input is not compilable
2 parents 2ed37d1 + 4cbefd8 commit 20926ef

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Sources/SwiftDriver/Jobs/EmitModuleJob.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ extension Driver {
9090

9191
// Add the inputs.
9292
for input in self.inputFiles where input.type.isPartOfSwiftCompilation {
93-
commandLine.append(.path(input.file))
93+
try addPathArgument(input.file, to: &commandLine)
9494
inputs.append(input)
9595
}
9696

@@ -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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,7 @@ final class SwiftDriverTests: XCTestCase {
30963096
func testWMOWithNonSourceInputFirstAndModuleOutput() throws {
30973097
var driver1 = try Driver(args: [
30983098
"swiftc", "-wmo", "danger.o", "foo.swift", "bar.swift", "wibble.swift", "-module-name", "Test",
3099-
"-driver-filelist-threshold=0", "-emit-module", "-emit-library"
3099+
"-driver-filelist-threshold=0", "-emit-module", "-emit-library", "-no-emit-module-separately-wmo"
31003100
])
31013101
let plannedJobs = try driver1.planBuild().removingAutolinkExtractJobs()
31023102
XCTAssertEqual(plannedJobs.count, 2)
@@ -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)