Skip to content

Commit 8991a53

Browse files
committed
Do not perform dependency scanning when no source inputs are specified
Resolves rdar://118900740
1 parent 0194450 commit 8991a53

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
@@ -2906,6 +2906,15 @@ final class SwiftDriverTests: XCTestCase {
29062906
XCTAssertEqual(firstKey, "foo.swift")
29072907
}
29082908

2909+
func testExplicitBuildWithJustObjectInputs() throws {
2910+
var driver = try Driver(args: [
2911+
"swiftc", "-explicit-module-build", "foo.o", "bar.o"
2912+
])
2913+
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
2914+
XCTAssertEqual(plannedJobs.count, 1)
2915+
XCTAssertEqual(plannedJobs.first?.kind, .link)
2916+
}
2917+
29092918
func testWMOWithNonSourceInputFirstAndModuleOutput() throws {
29102919
var driver1 = try Driver(args: [
29112920
"swiftc", "-wmo", "danger.o", "foo.swift", "bar.swift", "wibble.swift", "-module-name", "Test",

0 commit comments

Comments
 (0)