Skip to content

Commit 5553141

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

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ extension Driver {
292292
}
293293

294294
try addCommonFrontendOptions(commandLine: &commandLine, inputs: &inputs, kind: .compile,
295-
explicitModulePlanner: explicitModulePlanner)
295+
explicitModulePlanner: explicitModulePlanner, forVariantEmitModule: false,
296+
forObject: outputType == .object)
296297
try addRuntimeLibraryFlags(commandLine: &commandLine)
297298

298299
if Driver.canDoCrossModuleOptimization(parsedOptions: &parsedOptions) &&
@@ -371,6 +372,9 @@ extension Driver {
371372
commandLine.appendFlag(map)
372373
}
373374

375+
if isFrontendArgSupported(.debugModulePath) {
376+
try commandLine.appendLast(.debugModulePath, from: &parsedOptions)
377+
}
374378
try commandLine.appendLast(.trackSystemDependencies, from: &parsedOptions)
375379
try commandLine.appendLast(.CrossModuleOptimization, from: &parsedOptions)
376380
try commandLine.appendLast(.EnableCMOEverything, from: &parsedOptions)

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ extension Driver {
5858
kind: Job.Kind,
5959
bridgingHeaderHandling: BridgingHeaderHandling = .precompiled,
6060
explicitModulePlanner: ExplicitDependencyBuildPlanner? = nil,
61-
forVariantEmitModule: Bool = false
61+
forVariantEmitModule: Bool = false,
62+
forObject: Bool = false
6263
) throws {
6364
// Only pass -target to the REPL or immediate modes if it was explicitly
6465
// specified on the command line.
@@ -108,6 +109,12 @@ extension Driver {
108109
jobNeedPathRemap = false
109110
}
110111

112+
if isPlanJobForExplicitModule && forObject && isFrontendArgSupported(.debugModulePath),
113+
let explicitModulePlanner {
114+
let mainModule = explicitModulePlanner.dependencyGraph.mainModule
115+
try addPathOption(option: .debugModulePath, path: VirtualPath.lookup(mainModule.modulePath.path), to: &commandLine, remap: jobNeedPathRemap)
116+
}
117+
111118
// Check if dependency scanner has put the job into direct clang cc1 mode.
112119
// If dependency scanner put us into direct cc1 mode, avoid adding `-Xcc` options, since
113120
// dependency scanner already adds needed flags and -Xcc options known by swift-driver are
@@ -290,6 +297,7 @@ extension Driver {
290297
}
291298
try commandLine.appendAll(.D, from: &parsedOptions)
292299
try commandLine.appendAll(.debugPrefixMap, .coveragePrefixMap, .filePrefixMap, from: &parsedOptions)
300+
try commandLine.appendLast(.debugModulePath, from: &parsedOptions)
293301
try commandLine.appendAllArguments(.Xfrontend, from: &parsedOptions)
294302
try commandLine.appendLast(.warnConcurrency, from: &parsedOptions)
295303
if isFrontendArgSupported(.noAllocations) {

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.debugModulePath, 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 && driver.isFrontendArgSupported(.debugModulePath) {
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)