Skip to content

Commit 195f047

Browse files
authored
Merge pull request #2342 from aciidb0mb3r/debug
[Build] Generate dSYM in release mode
2 parents 8c621d7 + 153a40a commit 195f047

File tree

2 files changed

+46
-43
lines changed

2 files changed

+46
-43
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ public final class ClangTargetBuildDescription {
346346
}
347347
args += buildParameters.targetTripleArgs(for: target)
348348
args += buildParameters.toolchain.extraCCFlags
349+
args += ["-g"]
350+
if buildParameters.triple.isWindows() {
351+
args += ["-gcodeview"]
352+
}
349353
args += optimizationArguments
350354
args += activeCompilationConditions
351355
args += ["-fblocks"]
@@ -416,11 +420,7 @@ public final class ClangTargetBuildDescription {
416420
private var optimizationArguments: [String] {
417421
switch buildParameters.configuration {
418422
case .debug:
419-
if buildParameters.triple.isWindows() {
420-
return ["-g", "-gcodeview", "-O0"]
421-
} else {
422-
return ["-g", "-O0"]
423-
}
423+
return ["-O0"]
424424
case .release:
425425
return ["-O2"]
426426
}
@@ -553,6 +553,7 @@ public final class SwiftTargetBuildDescription {
553553
args += buildParameters.indexStoreArguments
554554
args += buildParameters.toolchain.extraSwiftCFlags
555555
args += optimizationArguments
556+
args += ["-g"]
556557
args += ["-j\(SwiftCompilerTool.numThreads)"]
557558
args += activeCompilationConditions
558559
args += additionalFlags
@@ -675,7 +676,7 @@ public final class SwiftTargetBuildDescription {
675676
private var optimizationArguments: [String] {
676677
switch buildParameters.configuration {
677678
case .debug:
678-
return ["-Onone", "-g", "-enable-testing"]
679+
return ["-Onone", "-enable-testing"]
679680
case .release:
680681
return ["-O"]
681682
}
@@ -785,13 +786,15 @@ public final class ProductBuildDescription {
785786
args += buildParameters.sanitizers.linkSwiftFlags()
786787
args += additionalFlags
787788

788-
if buildParameters.configuration == .debug {
789+
// Pass `-g` during a *release* build so the Swift driver emits a dSYM file for the binary.
790+
if buildParameters.configuration == .release {
789791
if buildParameters.triple.isWindows() {
790-
args += ["-Xlinker","-debug"]
792+
args += ["-Xlinker", "-debug"]
791793
} else {
792794
args += ["-g"]
793795
}
794796
}
797+
795798
args += ["-L", buildParameters.buildPath.pathString]
796799
args += ["-o", binary.pathString]
797800
args += ["-module-name", product.name.spm_mangledToC99ExtendedIdentifier()]

0 commit comments

Comments
 (0)