Skip to content

Commit 6c20096

Browse files
authored
Merge pull request #1347 from artemcm/DoNotPanicWMO-ItsJustALink
Do not attempt to create compilation jobs when no Swift source files are specified as inputs
2 parents f14ca3d + 1ac38c0 commit 6c20096

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,11 @@ extension Driver {
328328
addJobOutputs: ([TypedVirtualPath]) -> Void,
329329
emitModuleTrace: Bool
330330
) throws -> Job? {
331-
guard case .singleCompile = compilerMode
331+
guard case .singleCompile = compilerMode,
332+
inputFiles.allSatisfy({ $0.type.isPartOfSwiftCompilation })
332333
else { return nil }
333334

334-
if parsedOptions.hasArgument(.embedBitcode),
335-
inputFiles.allSatisfy({ $0.type.isPartOfSwiftCompilation }) {
335+
if parsedOptions.hasArgument(.embedBitcode) {
336336
let compile = try compileJob(primaryInputs: [],
337337
outputType: .llvmBitcode,
338338
addJobOutputs: addJobOutputs,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,6 +2875,15 @@ final class SwiftDriverTests: XCTestCase {
28752875
}
28762876
}
28772877

2878+
func testWMOWithJustObjectInputs() throws {
2879+
var driver = try Driver(args: [
2880+
"swiftc", "-wmo", "foo.o", "bar.o"
2881+
])
2882+
let plannedJobs = try driver.planBuild()
2883+
XCTAssertEqual(plannedJobs.count, 1)
2884+
XCTAssertEqual(plannedJobs.first?.kind, .link)
2885+
}
2886+
28782887
func testModuleAliasingWithImplicitBuild() throws {
28792888
var driver = try Driver(args: [
28802889
"swiftc", "foo.swift", "-module-name", "Foo", "-module-alias", "Car=Bar",

0 commit comments

Comments
 (0)