Skip to content

Commit 770f14b

Browse files
authored
Fix debug format override (#10018)
- use dwarf or dwarf-with-dsym based on build config in setting override - update options to not explicitly set the debug type to dwarf so that we may move this down to the build system someday to handle different formats on different platforms.
1 parent 39a7f30 commit 770f14b

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

Sources/CoreCommands/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public struct BuildOptions: ParsableArguments {
558558

559559
/// The Debug Information Format to use.
560560
@Option(name: .customLong("debug-info-format", withSingleDash: true), help: "The Debug Information Format to use.")
561-
public var debugInfoFormat: DebugInfoFormat = .dwarf
561+
public var debugInfoFormat: DebugInfoFormat? = nil
562562

563563
public var buildSystem: BuildSystemProvider.Kind {
564564
switch self._buildSystem {

Sources/CoreCommands/SwiftCommandState.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ public final class SwiftCommandState {
10201020
prepareForIndexing: prepareForIndexingMode,
10211021
enableXCFrameworksOnLinux: options.build.enableXCFrameworksOnLinux,
10221022
debuggingParameters: .init(
1023-
debugInfoFormat: self.options.build.debugInfoFormat.buildParameter,
1023+
debugInfoFormat: self.options.build.debugInfoFormat?.buildParameter,
10241024
triple: triple,
10251025
shouldEnableDebuggingEntitlement:
10261026
self.options.build
@@ -1484,4 +1484,3 @@ extension Basics.Diagnostic {
14841484
)
14851485
}
14861486
}
1487-

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ public final class PackagePIFBuilder {
670670
// Add the build settings that are specific to debug builds, and set those as the "Debug" configuration.
671671
var debugSettings = settings
672672
debugSettings[.COPY_PHASE_STRIP] = "NO"
673+
//TODO would be nice to have this defaulted by the build systems as we may want different default based on platform (ie codeview for windows)
673674
debugSettings[.DEBUG_INFORMATION_FORMAT] = "dwarf"
674675
debugSettings[.ENABLE_NS_ASSERTIONS] = "YES"
675676
debugSettings[.GCC_OPTIMIZATION_LEVEL] = "0"
@@ -684,6 +685,7 @@ public final class PackagePIFBuilder {
684685
// Add the build settings that are specific to release builds, and set those as the "Release" configuration.
685686
var releaseSettings = settings
686687
releaseSettings[.COPY_PHASE_STRIP] = "YES"
688+
//TODO would be nice to have this defaulted by the build systems as we may want different default based on platform (ie codeview for windows)
687689
releaseSettings[.DEBUG_INFORMATION_FORMAT] = "dwarf-with-dsym"
688690
releaseSettings[.GCC_OPTIMIZATION_LEVEL] = "s"
689691
releaseSettings[.SWIFT_OPTIMIZATION_LEVEL] = "-Owholemodule"

Sources/SwiftBuildSupport/SwiftBuildSystem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
997997
settings["ADD_TOOLCHAIN_CONCURRENCY_BACK_DEPLOY_RPATH"] = "YES"
998998
settings["ADD_TOOLCHAIN_SPAN_BACK_DEPLOY_RPATH"] = "YES"
999999

1000-
try settings.merge(Self.constructDebuggingSettingsOverrides(from: buildParameters.debuggingParameters), uniquingKeysWith: reportConflict)
1000+
try settings.merge(Self.constructDebuggingSettingsOverrides(from: buildParameters.debuggingParameters, for: buildParameters.configuration), uniquingKeysWith: reportConflict)
10011001
try settings.merge(Self.constructDriverSettingsOverrides(from: buildParameters.driverParameters), uniquingKeysWith: reportConflict)
10021002
try settings.merge(self.constructLinkerSettingsOverrides(from: buildParameters.linkingParameters, triple: buildParameters.triple), uniquingKeysWith: reportConflict)
10031003
try settings.merge(Self.constructTestingSettingsOverrides(from: buildParameters.testingParameters), uniquingKeysWith: reportConflict)
@@ -1159,15 +1159,15 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
11591159
return settings
11601160
}
11611161

1162-
private static func constructDebuggingSettingsOverrides(from parameters: BuildParameters.Debugging) -> [String: String] {
1162+
private static func constructDebuggingSettingsOverrides(from parameters: BuildParameters.Debugging, for configuration: BuildConfiguration) -> [String: String] {
11631163
var settings: [String: String] = [:]
11641164
if parameters.shouldEnableDebuggingEntitlement {
11651165
settings["DEPLOYMENT_POSTPROCESSING"] = "NO"
11661166
}
11671167
// Set DEBUG_INFORMATION_FORMAT based on debugInfoFormat
11681168
switch parameters.debugInfoFormat {
11691169
case .dwarf:
1170-
settings["DEBUG_INFORMATION_FORMAT"] = "dwarf"
1170+
settings["DEBUG_INFORMATION_FORMAT"] = configuration == .debug ? "dwarf" : "dwarf-with-dsym"
11711171
case .codeview:
11721172
settings["DEBUG_INFORMATION_FORMAT"] = "codeview"
11731173
case .none?:

0 commit comments

Comments
 (0)