Skip to content

Commit

Permalink
Merge pull request #1347 from artemcm/DoNotPanicWMO-ItsJustALink
Browse files Browse the repository at this point in the history
Do not attempt to create compilation jobs when no Swift source files are specified as inputs
  • Loading branch information
artemcm authored May 1, 2023
2 parents f14ca3d + 1ac38c0 commit 6c20096
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ extension Driver {
addJobOutputs: ([TypedVirtualPath]) -> Void,
emitModuleTrace: Bool
) throws -> Job? {
guard case .singleCompile = compilerMode
guard case .singleCompile = compilerMode,
inputFiles.allSatisfy({ $0.type.isPartOfSwiftCompilation })
else { return nil }

if parsedOptions.hasArgument(.embedBitcode),
inputFiles.allSatisfy({ $0.type.isPartOfSwiftCompilation }) {
if parsedOptions.hasArgument(.embedBitcode) {
let compile = try compileJob(primaryInputs: [],
outputType: .llvmBitcode,
addJobOutputs: addJobOutputs,
Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,15 @@ final class SwiftDriverTests: XCTestCase {
}
}

func testWMOWithJustObjectInputs() throws {
var driver = try Driver(args: [
"swiftc", "-wmo", "foo.o", "bar.o"
])
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 1)
XCTAssertEqual(plannedJobs.first?.kind, .link)
}

func testModuleAliasingWithImplicitBuild() throws {
var driver = try Driver(args: [
"swiftc", "foo.swift", "-module-name", "Foo", "-module-alias", "Car=Bar",
Expand Down

0 comments on commit 6c20096

Please sign in to comment.