Skip to content

Commit a01b99e

Browse files
committed
Do not perform dependency scanning when no source inputs are specified
Resolves rdar://118900740
1 parent 5ff4329 commit a01b99e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ extension Driver {
139139
IncrementalCompilationState.InitialStateForPlanning?)
140140
throws -> InterModuleDependencyGraph? {
141141
let interModuleDependencyGraph: InterModuleDependencyGraph?
142-
if parsedOptions.contains(.driverExplicitModuleBuild) ||
143-
parsedOptions.contains(.explainModuleDependency) {
142+
if (parsedOptions.contains(.driverExplicitModuleBuild) ||
143+
parsedOptions.contains(.explainModuleDependency)) &&
144+
inputFiles.contains(where: { $0.type.isPartOfSwiftCompilation }) {
144145
// If the incremental build record's module dependency graph is up-to-date, we
145146
// can skip dependency scanning entirely.
146147
interModuleDependencyGraph =

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,6 +2948,15 @@ final class SwiftDriverTests: XCTestCase {
29482948
XCTAssertEqual(firstKey, "foo.swift")
29492949
}
29502950

2951+
func testExplicitBuildWithJustObjectInputs() throws {
2952+
var driver = try Driver(args: [
2953+
"swiftc", "-explicit-module-build", "foo.o", "bar.o"
2954+
])
2955+
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
2956+
XCTAssertEqual(plannedJobs.count, 1)
2957+
XCTAssertEqual(plannedJobs.first?.kind, .link)
2958+
}
2959+
29512960
func testWMOWithNonSourceInputFirstAndModuleOutput() throws {
29522961
var driver1 = try Driver(args: [
29532962
"swiftc", "-wmo", "danger.o", "foo.swift", "bar.swift", "wibble.swift", "-module-name", "Test",

0 commit comments

Comments
 (0)