Skip to content

Commit 2472e9b

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

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
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: 10 additions & 1 deletion
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",
@@ -2924,7 +2933,7 @@ final class SwiftDriverTests: XCTestCase {
29242933
throw StringError("Unexpected argument for output file map")
29252934
}
29262935
let firstKeyHandle = try XCTUnwrap(outFileMap.entries.keys.first)
2927-
let firstKey = try VirtualPath.lookup(firstKeyHandle).description
2936+
let firstKey = VirtualPath.lookup(firstKeyHandle).description
29282937
XCTAssertEqual(firstKey, "foo.swift")
29292938
let firstKeyOutputs = try XCTUnwrap(outFileMap.entries[firstKeyHandle])
29302939
XCTAssertTrue(firstKeyOutputs.keys.contains(where: { $0 == .swiftModule }))

0 commit comments

Comments
 (0)