@@ -28,6 +28,12 @@ similar to the /Library or ~/Library directories on macOS.
28
28
. PARAMETER BuildType
29
29
The CMake build type to use, one of: Release, RelWithDebInfo, Debug.
30
30
31
+ . PARAMETER CDebugFormat
32
+ The debug information format for C/C++ code: dwarf or codeview.
33
+
34
+ . PARAMETER SwiftDebugFormat
35
+ The debug information format for Swift code: dwarf or codeview.
36
+
31
37
. PARAMETER SDKs
32
38
An array of architectures for which the Swift SDK should be built.
33
39
70
76
[string ] $BinaryCache = " S:\b" ,
71
77
[string ] $LibraryRoot = " S:\Library" ,
72
78
[string ] $BuildType = " Release" ,
79
+ [string ] $CDebugFormat = " dwarf" ,
80
+ [string ] $SwiftDebugFormat = " dwarf" ,
73
81
[string []] $SDKs = @ (" X64" , " X86" , " Arm64" ),
74
82
[string ] $ProductVersion = " 0.0.0" ,
75
83
[switch ] $SkipBuild = $false ,
@@ -352,8 +360,8 @@ function Build-CMakeProject {
352
360
TryAdd- KeyValue $Defines CMAKE_BUILD_TYPE $BuildType
353
361
TryAdd- KeyValue $Defines CMAKE_MT " mt"
354
362
355
- $IsRelease = $Defines [" CMAKE_BUILD_TYPE" ] -eq " Release"
356
- $Zi = if ($IsRelease ) { " " } else { " /Zi " }
363
+ $GenerateDebugInfo = $Defines [" CMAKE_BUILD_TYPE" ] -ne " Release"
364
+ $Zi = if ($GenerateDebugInfo ) { " /Zi " } else { " " }
357
365
358
366
$CFlags = " /GS- /Gw /Gy /Oi /Oy $Zi /Zc:inline"
359
367
$CXXFlags = " /GS- /Gw /Gy /Oi /Oy $Zi /Zc:inline /Zc:__cplusplus"
@@ -373,15 +381,15 @@ function Build-CMakeProject {
373
381
if ($UseBuiltCompilers.Contains (" C" )) {
374
382
TryAdd- KeyValue $Defines CMAKE_C_COMPILER " $BinaryCache \1\bin\clang-cl.exe"
375
383
TryAdd- KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
376
- if (-not $IsRelease ) {
384
+ if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf " ) {
377
385
Append- FlagsDefine $Defines CMAKE_C_FLAGS - gdwarf
378
386
}
379
387
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
380
388
}
381
389
if ($UseBuiltCompilers.Contains (" CXX" )) {
382
390
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER " $BinaryCache \1\bin\clang-cl.exe"
383
391
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
384
- if (-not $IsRelease ) {
392
+ if ($GenerateDebugInfo -and $CDebugFormat -eq " dwarf " ) {
385
393
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS - gdwarf
386
394
}
387
395
Append- FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
@@ -404,18 +412,16 @@ function Build-CMakeProject {
404
412
}
405
413
406
414
# Debug Information
407
- if ($IsRelease ) {
408
- $SwiftArgs.Add (" -gnone" ) | Out-Null
415
+ if ($GenerateDebugInfo ) {
416
+ if ($SwiftDebugFormat -eq " dwarf" ) {
417
+ $SwiftArgs.Add (" -g -Xlinker /DEBUG:DWARF -use-ld=lld-link" ) | Out-Null
418
+ } else {
419
+ $SwiftArgs.Add (" -g -debug-info-format=codeview -Xlinker -debug" ) | Out-Null
420
+ }
409
421
} else {
410
- # $SwiftArgs.Add("-g -debug-info-format=codeview") | Out-Null
411
- $SwiftArgs.Add (" -g" ) | Out-Null
412
- $SwiftArgs.Add (" -use-ld=lld-link" ) | Out-Null
422
+ $SwiftArgs.Add (" -gnone" ) | Out-Null
413
423
}
414
424
$SwiftArgs.Add (" -Xlinker /INCREMENTAL:NO" ) | Out-Null
415
- if (-not $IsRelease ) {
416
- # $SwiftArgs.Add("-Xlinker -debug") | Out-Null
417
- $SwiftArgs.Add (" -Xlinker /DEBUG:DWARF" ) | Out-Null
418
- }
419
425
420
426
# Swift Requries COMDAT folding and de-duplication
421
427
$SwiftArgs.Add (" -Xlinker /OPT:REF" ) | Out-Null
0 commit comments