From 24d30947b64a851455af361fe3d15166f76a2f39 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 14 Dec 2023 15:21:49 -0800 Subject: [PATCH] SwiftDriver: repair the generation of CodeView debug info Correct the spelling for the argument for the `-debug-info-format`. We were incorrectly emitting the enum name instead of the value, which would break the build when CodeView was enabled. --- Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift | 2 +- Tests/SwiftDriverTests/SwiftDriverTests.swift | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift index 496456714..8945cedd4 100644 --- a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift +++ b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift @@ -196,7 +196,7 @@ extension Driver { try commandLine.appendLast(.enablePrivateImports, from: &parsedOptions) try commandLine.appendLast(in: .g, from: &parsedOptions) if debugInfo.level != nil { - commandLine.appendFlag("-debug-info-format=\(debugInfo.format)") + commandLine.appendFlag("-debug-info-format=\(debugInfo.format.rawValue)") if isFrontendArgSupported(.dwarfVersion) { commandLine.appendFlag("-dwarf-version=\(debugInfo.dwarfVersion)") } diff --git a/Tests/SwiftDriverTests/SwiftDriverTests.swift b/Tests/SwiftDriverTests/SwiftDriverTests.swift index 5eacd2e41..e19dacb70 100644 --- a/Tests/SwiftDriverTests/SwiftDriverTests.swift +++ b/Tests/SwiftDriverTests/SwiftDriverTests.swift @@ -560,6 +560,16 @@ final class SwiftDriverTests: XCTestCase { try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-g", "-debug-info-format=codeview") { driver in XCTAssertEqual(driver.debugInfo.level, .astTypes) XCTAssertEqual(driver.debugInfo.format, .codeView) + + let jobs = try driver.planBuild() + XCTAssertTrue(jobs[0].commandLine.contains(.flag("-debug-info-format=codeview"))) + } + + try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-g", "-debug-info-format=dwarf") { driver in + XCTAssertEqual(driver.debugInfo.format, .dwarf) + + let jobs = try driver.planBuild() + XCTAssertTrue(jobs[0].commandLine.contains(.flag("-debug-info-format=dwarf"))) } try assertDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-debug-info-format=dwarf") {