Skip to content

Commit 9f7942c

Browse files
Merge pull request #2020 from swiftlang/eng/PR-164524241-6.3
[-debug-module-path] Prefer the moduleOutputInfo.output path if avail…
2 parents bd76e04 + 600e97a commit 9f7942c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ extension Driver {
112112
if isPlanJobForExplicitModule && forObject && isFrontendArgSupported(.debugModulePath),
113113
let explicitModulePlanner {
114114
let mainModule = explicitModulePlanner.dependencyGraph.mainModule
115-
try addPathOption(option: .debugModulePath, path: VirtualPath.lookup(mainModule.modulePath.path), to: &commandLine, remap: jobNeedPathRemap)
115+
let pathHandle = moduleOutputInfo.output?.outputPath ?? mainModule.modulePath.path
116+
let path = VirtualPath.lookup(pathHandle)
117+
try addPathOption(option: .debugModulePath, path: path, to: &commandLine, remap: jobNeedPathRemap)
116118
}
117119

118120
// Check if dependency scanner has put the job into direct clang cc1 mode.

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,24 @@ final class ExplicitModuleBuildTests: XCTestCase {
11511151
let baseName = "testExplicitModuleVerifyInterfaceJobs"
11521152
XCTAssertTrue(matchTemporary(outputFilePath, basename: baseName, fileExtension: "o") ||
11531153
matchTemporary(outputFilePath, basename: baseName, fileExtension: "autolink"))
1154+
if outputFilePath.extension == FileType.object.rawValue && driver.isFrontendArgSupported(.debugModulePath) {
1155+
// Check that this is an absolute path pointing to the temporary directory.
1156+
var found : Bool = false
1157+
for arg in job.commandLine {
1158+
if !found && arg == "-debug-module-path" {
1159+
found = true
1160+
} else if found {
1161+
if case let .path(vpath) = arg {
1162+
XCTAssertTrue(vpath.isTemporary)
1163+
XCTAssertTrue(vpath.extension == FileType.swiftModule.rawValue)
1164+
} else {
1165+
XCTFail("argument is not a path")
1166+
}
1167+
break
1168+
}
1169+
}
1170+
XCTAssertTrue(found)
1171+
}
11541172
default:
11551173
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
11561174
}

0 commit comments

Comments
 (0)