Skip to content

Commit 95d3903

Browse files
committed
[SIL] Simplify debug info generation flow for SIL files
- Now `-g` implies `-Xllvm -sil-print-debuginfo` if the output file format is SIL. - The `-gsil` is renamed into `-sil-based-debuginfo`.
1 parent 8e8a56d commit 95d3903

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ extension Driver {
240240
if shouldSupportAnonymousContextMangledNames {
241241
commandLine.appendFlag(.enableAnonymousContextMangledNames)
242242
}
243+
244+
if compilerOutputType == .sil {
245+
commandLine.appendFlag("-Xllvm")
246+
commandLine.appendFlag("-sil-print-debuginfo")
247+
}
243248
}
244249

245250
// Pass through any subsystem flags.

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ extension Option {
336336
public static let glineTablesOnly: Option = Option("-gline-tables-only", .flag, attributes: [.frontend], helpText: "Emit minimal debug info for backtraces only", group: .g)
337337
public static let gnone: Option = Option("-gnone", .flag, attributes: [.frontend], helpText: "Don't emit debug info", group: .g)
338338
public static let groupInfoPath: Option = Option("-group-info-path", .separate, attributes: [.helpHidden, .frontend, .noDriver], helpText: "The path to collect the group information of the compiled module")
339-
public static let debugOnSil: Option = Option("-gsil", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Write the SIL into a file and generate debug-info to debug on SIL level.")
339+
public static let debugOnSil: Option = Option("-sil-based-debuginfo", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Write the SIL into a file and generate debug-info to debug on SIL level.")
340340
public static let g: Option = Option("-g", .flag, attributes: [.frontend], helpText: "Emit debug info. This is the preferred setting for debugging with LLDB.", group: .g)
341341
public static let helpHidden: Option = Option("-help-hidden", .flag, attributes: [.helpHidden, .frontend], helpText: "Display available options, including hidden options")
342342
public static let helpHidden_: Option = Option("--help-hidden", .flag, alias: Option.helpHidden, attributes: [.helpHidden, .frontend], helpText: "Display available options, including hidden options")

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ final class SwiftDriverTests: XCTestCase {
421421
try assertDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-gdwarf-types", "-debug-info-format=codeview") {
422422
$1.expect(.error("argument '-debug-info-format=codeview' is not allowed with '-gdwarf-types'"))
423423
}
424+
425+
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-emit-sil") { driver in
426+
let jobs = try driver.planBuild()
427+
XCTAssertTrue(jobs[0].commandLine.contains(.flag("-Xllvm")))
428+
XCTAssertTrue(jobs[0].commandLine.contains(.flag("-sil-print-debuginfo")))
429+
}
424430
}
425431

426432
func testCoverageSettings() throws {

0 commit comments

Comments
 (0)