diff --git a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift index 2d79a0ccc..a251a0607 100644 --- a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift +++ b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift @@ -392,11 +392,15 @@ extension Driver { try addPathArgument(.absolute(workingDirectory), to: &commandLine, remap: jobNeedPathRemap) } - // Resource directory. - try addPathOption(option: .resourceDir, - path: VirtualPath.lookup(frontendTargetInfo.runtimeResourcePath.path), - to: &commandLine, - remap: jobNeedPathRemap) + // Only pass in a resource directory to the frontend if one was passed to + // swift-driver. Make an exception for scan-dependencies jobs for now till + // we figure out a remaining problem with in-process scanning. + if parsedOptions.hasArgument(.resourceDir) || kind == .scanDependencies { + try addPathOption(option: .resourceDir, + path: VirtualPath.lookup(frontendTargetInfo.runtimeResourcePath.path), + to: &commandLine, + remap: jobNeedPathRemap) + } if self.useStaticResourceDir { commandLine.appendFlag("-use-static-resource-dir") diff --git a/Tests/SwiftDriverTests/SwiftDriverTests.swift b/Tests/SwiftDriverTests/SwiftDriverTests.swift index 1ae33d985..ad25a720e 100644 --- a/Tests/SwiftDriverTests/SwiftDriverTests.swift +++ b/Tests/SwiftDriverTests/SwiftDriverTests.swift @@ -860,8 +860,10 @@ final class SwiftDriverTests: XCTestCase { let plannedJobs = try driver1.planBuild().removingAutolinkExtractJobs() XCTAssertEqual(plannedJobs.count, 3) XCTAssertEqual(plannedJobs[0].outputs.count, 1) + XCTAssert(!plannedJobs[0].commandLine.contains(.flag("-resource-dir"))) XCTAssertTrue(matchTemporary(plannedJobs[0].outputs.first!.file, "foo.o")) XCTAssertEqual(plannedJobs[1].outputs.count, 1) + XCTAssert(!plannedJobs[1].commandLine.contains(.flag("-resource-dir"))) XCTAssertTrue(matchTemporary(plannedJobs[1].outputs.first!.file, "bar.o")) XCTAssertTrue(plannedJobs[2].tool.name.contains(executableName("clang"))) XCTAssertEqual(plannedJobs[2].outputs.count, 1)