@@ -346,6 +346,10 @@ public final class ClangTargetBuildDescription {
346
346
}
347
347
args += buildParameters. targetTripleArgs ( for: target)
348
348
args += buildParameters. toolchain. extraCCFlags
349
+ args += [ " -g " ]
350
+ if buildParameters. triple. isWindows ( ) {
351
+ args += [ " -gcodeview " ]
352
+ }
349
353
args += optimizationArguments
350
354
args += activeCompilationConditions
351
355
args += [ " -fblocks " ]
@@ -416,11 +420,7 @@ public final class ClangTargetBuildDescription {
416
420
private var optimizationArguments : [ String ] {
417
421
switch buildParameters. configuration {
418
422
case . debug:
419
- if buildParameters. triple. isWindows ( ) {
420
- return [ " -g " , " -gcodeview " , " -O0 " ]
421
- } else {
422
- return [ " -g " , " -O0 " ]
423
- }
423
+ return [ " -O0 " ]
424
424
case . release:
425
425
return [ " -O2 " ]
426
426
}
@@ -553,6 +553,7 @@ public final class SwiftTargetBuildDescription {
553
553
args += buildParameters. indexStoreArguments
554
554
args += buildParameters. toolchain. extraSwiftCFlags
555
555
args += optimizationArguments
556
+ args += [ " -g " ]
556
557
args += [ " -j \( SwiftCompilerTool . numThreads) " ]
557
558
args += activeCompilationConditions
558
559
args += additionalFlags
@@ -675,7 +676,7 @@ public final class SwiftTargetBuildDescription {
675
676
private var optimizationArguments : [ String ] {
676
677
switch buildParameters. configuration {
677
678
case . debug:
678
- return [ " -Onone " , " -g " , " - enable-testing" ]
679
+ return [ " -Onone " , " -enable-testing " ]
679
680
case . release:
680
681
return [ " -O " ]
681
682
}
@@ -785,13 +786,15 @@ public final class ProductBuildDescription {
785
786
args += buildParameters. sanitizers. linkSwiftFlags ( )
786
787
args += additionalFlags
787
788
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 {
789
791
if buildParameters. triple. isWindows ( ) {
790
- args += [ " -Xlinker " , " -debug " ]
792
+ args += [ " -Xlinker " , " -debug " ]
791
793
} else {
792
794
args += [ " -g " ]
793
795
}
794
796
}
797
+
795
798
args += [ " -L " , buildParameters. buildPath. pathString]
796
799
args += [ " -o " , binary. pathString]
797
800
args += [ " -module-name " , product. name. spm_mangledToC99ExtendedIdentifier ( ) ]
0 commit comments