@@ -905,6 +905,7 @@ function Build-CMakeProject {
905
905
[string []] $UsePinnedCompilers = @ (), # ASM,C,CXX,Swift
906
906
[switch ] $UseSwiftSwiftDriver = $false ,
907
907
[switch ] $AddAndroidCMakeEnv = $false ,
908
+ [switch ] $UseGNUDriver = $false ,
908
909
[string ] $SwiftSDK = " " ,
909
910
[hashtable ] $Defines = @ {}, # Values are either single strings or arrays of flags
910
911
[string []] $BuildTargets = @ ()
@@ -992,15 +993,19 @@ function Build-CMakeProject {
992
993
$CFlags = @ ()
993
994
switch ($Platform ) {
994
995
Windows {
995
- $CFlags = @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
996
+ $CFlags = if ($UseGNUDriver ) {
997
+ @ (" -fno-stack-protector" , " -ffunction-sections" , " -fdata-sections" , " -fomit-frame-pointer" )
998
+ } else {
999
+ @ (" /GS-" , " /Gw" , " /Gy" , " /Oi" , " /Oy" , " /Zc:inline" )
1000
+ }
996
1001
}
997
1002
Android {
998
1003
$CFlags = @ (" --sysroot=$ ( Get-AndroidNDKPath ) \toolchains\llvm\prebuilt\windows-x86_64\sysroot" )
999
1004
}
1000
1005
}
1001
1006
1002
1007
$CXXFlags = @ ()
1003
- if ($Platform -eq " Windows" ) {
1008
+ if ($Platform -eq " Windows" -and -not $UseGNUDriver ) {
1004
1009
$CXXFlags += $CFlags.Clone () + @ (" /Zc:__cplusplus" )
1005
1010
}
1006
1011
@@ -1011,8 +1016,13 @@ function Build-CMakeProject {
1011
1016
Append- FlagsDefine $Defines CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded
1012
1017
Append- FlagsDefine $Defines CMAKE_POLICY_CMP0141 NEW
1013
1018
# Add additional linker flags for generating the debug info.
1014
- Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " /debug"
1015
- Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " /debug"
1019
+ if ($UseGNUDriver ) {
1020
+ Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " -Xlinker -debug"
1021
+ Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " -Xlinker -debug"
1022
+ } else {
1023
+ Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " /debug"
1024
+ Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " /debug"
1025
+ }
1016
1026
} elseif ($Platform -eq " Android" ) {
1017
1027
# Use a built lld linker as the Android's NDK linker might be too
1018
1028
# old and not support all required relocations needed by the Swift
@@ -1050,7 +1060,7 @@ function Build-CMakeProject {
1050
1060
}
1051
1061
}
1052
1062
if ($UsePinnedCompilers.Contains (" C" ) -Or $UseBuiltCompilers.Contains (" C" )) {
1053
- $Driver = if ($Platform -eq " Windows" ) { " clang-cl.exe" } else { " clang.exe" }
1063
+ $Driver = if ($Platform -eq " Windows" -and -not $UseGNUDriver ) { " clang-cl.exe" } else { " clang.exe" }
1054
1064
if ($UseBuiltCompilers.Contains (" C" )) {
1055
1065
TryAdd- KeyValue $Defines CMAKE_C_COMPILER ([IO.Path ]::Combine($CompilersBinaryCache , " bin" , $Driver ))
1056
1066
} else {
@@ -1064,7 +1074,7 @@ function Build-CMakeProject {
1064
1074
Append- FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
1065
1075
}
1066
1076
if ($UsePinnedCompilers.Contains (" CXX" ) -Or $UseBuiltCompilers.Contains (" CXX" )) {
1067
- $Driver = if ($Platform -eq " Windows" ) { " clang-cl.exe" } else { " clang++.exe" }
1077
+ $Driver = if ($Platform -eq " Windows" -and -not $UseGNUDriver ) { " clang-cl.exe" } else { " clang++.exe" }
1068
1078
if ($UseBuiltCompilers.Contains (" CXX" )) {
1069
1079
TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER ([IO.Path ]::Combine($CompilersBinaryCache , " bin" , $Driver ))
1070
1080
} else {
0 commit comments