Skip to content

Commit 600e97a

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 (Relanding with a relaxed test that doesn't encode the name of a temporary file) (cherry picked from commit 3999166)
1 parent c3e6a55 commit 600e97a

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
@@ -1075,6 +1075,24 @@ 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.rawValue && driver.isFrontendArgSupported(.debugModulePath) {
1079+
// Check that this is an absolute path pointing to the temporary directory.
1080+
var found : Bool = false
1081+
for arg in job.commandLine {
1082+
if !found && arg == "-debug-module-path" {
1083+
found = true
1084+
} else if found {
1085+
if case let .path(vpath) = arg {
1086+
XCTAssertTrue(vpath.isTemporary)
1087+
XCTAssertTrue(vpath.extension == FileType.swiftModule.rawValue)
1088+
} else {
1089+
XCTFail("argument is not a path")
1090+
}
1091+
break
1092+
}
1093+
}
1094+
XCTAssertTrue(found)
1095+
}
10781096
default:
10791097
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
10801098
}

0 commit comments

Comments
 (0)