Skip to content

Commit 16b16a0

Browse files
committed
Pass -module-path to EBM-enabled compile jobs
rdar://151822009
1 parent c54107d commit 16b16a0

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ extension Driver {
108108
jobNeedPathRemap = false
109109
}
110110

111+
if isPlanJobForExplicitModule && kind == .compile,
112+
let explicitModulePlanner {
113+
let mainModule = explicitModulePlanner.dependencyGraph.mainModule
114+
try addPathOption(option: .debugModulePath, path: VirtualPath.lookup(mainModule.modulePath.path), to: &commandLine, remap: jobNeedPathRemap)
115+
}
116+
111117
// Check if dependency scanner has put the job into direct clang cc1 mode.
112118
// If dependency scanner put us into direct cc1 mode, avoid adding `-Xcc` options, since
113119
// dependency scanner already adds needed flags and -Xcc options known by swift-driver are

Sources/SwiftOptions/Options.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ extension Option {
129129
public static let debugInverseRequirements: Option = Option("-debug-inverse-requirements", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Print real requirements in -debug-generic-signatures output")
130130
public static let debugMapping: Option = Option("-debug-mapping", .flag, attributes: [.noDriver], helpText: "Dumping information for debug purposes")
131131
public static let debugMapping_: Option = Option("--debug-mapping", .flag, alias: Option.debugMapping, attributes: [.noDriver], helpText: "Dumping information for debug purposes")
132+
public static let debugModulePathEQ: Option = Option("-debug-module-path=", .joined, alias: Option.debugModulePathEQ, attributes: [.frontend])
133+
public static let debugModulePath: Option = Option("-debug-module-path", .separate, attributes: [.frontend], helpText: "Path to this module's binary swiftmodule artifact (required by debug info)")
132134
public static let debugPrefixMap: Option = Option("-debug-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap source paths in debug info")
133135
public static let debugRequirementMachine: Option = Option("-debug-requirement-machine=", .joined, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Fine-grained debug output from the generics implementation")
134136
public static let debugTimeExpressionTypeChecking: Option = Option("-debug-time-expression-type-checking", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Dumps the time it takes to type-check each expression")
@@ -1554,6 +1556,8 @@ extension Option {
15541556
Option.explicitAutoLinking,
15551557
Option.explicitDependencyGraphFormat,
15561558
Option.explicitInterfaceModuleBuild,
1559+
Option.debugModulePathEQ,
1560+
Option.debugModulePath,
15571561
Option.driverExplicitModuleBuild,
15581562
Option.explicitSwiftModuleMap,
15591563
Option.exportAs,

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
718718
for job in jobs {
719719
XCTAssertEqual(job.outputs.count, 1)
720720
let outputFilePath = job.outputs[0].file
721+
if job.kind == .compile {
722+
XCTAssertTrue(job.commandLine.contains(subsequence: ["-debug-module-path", try toPathOption("testExplicitModuleBuildJobs.swiftmodule")]))
723+
724+
}
721725

722726
// Swift dependencies
723727
if outputFilePath.extension != nil,

0 commit comments

Comments
 (0)