Skip to content

Commit

Permalink
Do not perform dependency scanning when no source inputs are specified
Browse files Browse the repository at this point in the history
Resolves rdar://118900740
  • Loading branch information
artemcm committed Nov 28, 2023
1 parent 0194450 commit 8991a53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ extension Driver {
IncrementalCompilationState.InitialStateForPlanning?)
throws -> InterModuleDependencyGraph? {
let interModuleDependencyGraph: InterModuleDependencyGraph?
if parsedOptions.contains(.driverExplicitModuleBuild) ||
parsedOptions.contains(.explainModuleDependency) {
if (parsedOptions.contains(.driverExplicitModuleBuild) ||
parsedOptions.contains(.explainModuleDependency)) &&
inputFiles.contains(where: { $0.type.isPartOfSwiftCompilation }) {
// If the incremental build record's module dependency graph is up-to-date, we
// can skip dependency scanning entirely.
interModuleDependencyGraph =
Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,15 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertEqual(firstKey, "foo.swift")
}

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

func testWMOWithNonSourceInputFirstAndModuleOutput() throws {
var driver1 = try Driver(args: [
"swiftc", "-wmo", "danger.o", "foo.swift", "bar.swift", "wibble.swift", "-module-name", "Test",
Expand Down

0 comments on commit 8991a53

Please sign in to comment.