Skip to content

Commit d9c3e6d

Browse files
committed
[-debug-module-path] Prefer the moduleOutputInfo.output path if available.
While testing the LLDB support for enhanced module tracking I noticed that the driver currently always uses a relative path for -debug-module-path, which is an obvious problem when compiling in a different directory, or if the swift module output is in a different path than the object file output. This patch addresses this by preferring moduleOutputInfo.output if available. rdar://164524241
1 parent c3e6a55 commit d9c3e6d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
10751075
let baseName = "testExplicitModuleVerifyInterfaceJobs"
10761076
XCTAssertTrue(matchTemporary(outputFilePath, basename: baseName, fileExtension: "o") ||
10771077
matchTemporary(outputFilePath, basename: baseName, fileExtension: "autolink"))
1078+
if outputFilePath.extension == FileType.object.extension && driver.isFrontendArgSupported(.debugModulePath) {
1079+
// Check that this is an absolute path pointing to the temporary directory.
1080+
XCTAssertTrue(job.commandLine.contains(subsequence: ["-debug-module-path", .path(.temporary(try RelativePath(validating: "testExplicitModuleVerifyInterfaceJobs-3.swiftmodule")))]))
1081+
}
10781082
default:
10791083
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
10801084
}

0 commit comments

Comments
 (0)