Skip to content

Commit 7ed6a55

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

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: .modulePath, 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
@@ -707,6 +707,8 @@ extension Option {
707707
public static let moduleLoadMode: Option = Option("-module-load-mode", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "only-interface|prefer-interface|prefer-serialized|only-serialized", helpText: "Module loading mode")
708708
public static let moduleNameEQ: Option = Option("-module-name=", .joined, alias: Option.moduleName, attributes: [.frontend])
709709
public static let moduleName: Option = Option("-module-name", .separate, attributes: [.frontend, .synthesizeInterface, .moduleInterface], helpText: "Name of the module to build")
710+
public static let modulePathEQ: Option = Option("-module-path=", .joined, alias: Option.modulePathEQ, attributes: [.frontend])
711+
public static let modulePath: Option = Option("-module-path", .separate, attributes: [.frontend], helpText: "Path to this module's binary swiftmodule artifact (required by debug info)")
710712
public static let module: Option = Option("-module", .separate, attributes: [.noDriver], metaVar: "<name>", helpText: "Names of modules")
711713
public static let module_: Option = Option("--module", .separate, alias: Option.module, attributes: [.noDriver], metaVar: "<name>", helpText: "Names of modules")
712714
public static let newDriverPath: Option = Option("-new-driver-path", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<path>", helpText: "Path of the new driver to be used")
@@ -1694,6 +1696,8 @@ extension Option {
16941696
Option.moduleLoadMode,
16951697
Option.moduleNameEQ,
16961698
Option.moduleName,
1699+
Option.modulePathEQ,
1700+
Option.modulePath,
16971701
Option.module,
16981702
Option.module_,
16991703
Option.newDriverPath,

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: ["-module-path", try toPathOption("testExplicitModuleBuildJobs.swiftmodule")]))
723+
724+
}
721725

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

0 commit comments

Comments
 (0)