@@ -88,11 +88,23 @@ function Invoke-VsDevShell($Arch)
88
88
Check- LastExitCode
89
89
}
90
90
91
- function TryAddKeyValue ([hashtable ]$Hashtable , [string ]$Key , [string ]$Value )
91
+ function TryAdd-Define ([hashtable ]$Defines , [string ]$Name , [string ]$Value )
92
92
{
93
- if (-not $Hashtable .Contains ($Key ))
93
+ if (-not $Defines .Contains ($Name ))
94
94
{
95
- $Hashtable.Add ($Key , $Value )
95
+ $Defines.Add ($Name , $Value )
96
+ }
97
+ }
98
+
99
+ function Append-FlagsDefine ([hashtable ]$Defines , [string ]$Name , [string ]$Value )
100
+ {
101
+ if ($Defines.Contains ($Name ))
102
+ {
103
+ $Defines [$name ] += " $Value "
104
+ }
105
+ else
106
+ {
107
+ $Defines.Add ($Name , $Value )
96
108
}
97
109
}
98
110
@@ -126,57 +138,57 @@ function Build-CMakeProject
126
138
127
139
# Add additional defines (unless already present)
128
140
$Defines = $Defines.Clone ()
129
- TryAddKeyValue $Defines CMAKE_BUILD_TYPE $BuildType
130
- TryAddKeyValue $Defines CMAKE_MT " mt"
141
+ TryAdd - Define $Defines CMAKE_BUILD_TYPE $BuildType
142
+ TryAdd - Define $Defines CMAKE_MT " mt"
131
143
132
144
$CFlags = " /GS- /Gw /Gy /Oi /Oy /Zi /Zc:inline"
133
145
$CXXFlags = " /GS- /Gw /Gy /Oi /Oy /Zi /Zc:inline /Zc:__cplusplus"
134
146
if ($UseMSVCCompilers.Contains (" C" ))
135
147
{
136
- TryAddKeyValue $Defines CMAKE_C_COMPILER cl
137
- TryAddKeyValue $Defines CMAKE_C_FLAGS $CFlags
148
+ TryAdd - Define $Defines CMAKE_C_COMPILER cl
149
+ Append - FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
138
150
}
139
151
if ($UseMSVCCompilers.Contains (" CXX" ))
140
152
{
141
- TryAddKeyValue $Defines CMAKE_CXX_COMPILER cl
142
- TryAddKeyValue $Defines CMAKE_CXX_FLAGS $CXXFlags
153
+ TryAdd - Define $Defines CMAKE_CXX_COMPILER cl
154
+ Append - FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
143
155
}
144
156
if ($UseBuiltCompilers.Contains (" ASM" )) {
145
- TryAddKeyValue $Defines CMAKE_ASM_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
146
- TryAddKeyValue $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
147
- TryAddKeyValue $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL " /MD"
157
+ TryAdd - Define $Defines CMAKE_ASM_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
158
+ Append - FlagsDefine $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
159
+ TryAdd - Define $Defines CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL " /MD"
148
160
}
149
161
if ($UseBuiltCompilers.Contains (" C" )) {
150
- TryAddKeyValue $Defines CMAKE_C_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
151
- TryAddKeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
152
- TryAddKeyValue $Defines CMAKE_C_FLAGS $CFlags
162
+ TryAdd - Define $Defines CMAKE_C_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
163
+ TryAdd - Define $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
164
+ Append - FlagsDefine $Defines CMAKE_C_FLAGS $CFlags
153
165
}
154
166
if ($UseBuiltCompilers.Contains (" CXX" )) {
155
- TryAddKeyValue $Defines CMAKE_CXX_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
156
- TryAddKeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
157
- TryAddKeyValue $Defines CMAKE_CXX_FLAGS $CXXFlags
167
+ TryAdd - Define $Defines CMAKE_CXX_COMPILER S:/ b/ 1 / bin/ clang-cl.exe
168
+ TryAdd - Define $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
169
+ Append - FlagsDefine $Defines CMAKE_CXX_FLAGS $CXXFlags
158
170
}
159
171
if ($UseBuiltCompilers.Contains (" Swift" )) {
160
- TryAddKeyValue $Defines CMAKE_Swift_COMPILER S:/ b/ 1 / bin/ swiftc.exe
161
- TryAddKeyValue $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
172
+ TryAdd - Define $Defines CMAKE_Swift_COMPILER S:/ b/ 1 / bin/ swiftc.exe
173
+ TryAdd - Define $Defines CMAKE_Swift_COMPILER_TARGET $Arch.LLVMTarget
162
174
163
175
$RuntimeBuildDir = Get-ProjectBuildDir $Arch 1
164
176
$SwiftResourceDir = " ${RuntimeBuildDir} \lib\swift"
165
177
$SwiftcFlags = @ (
166
178
" -resource-dir $SwiftResourceDir " ,
167
- " -L $SwiftResourceDir \windows" ,
168
- " -vfsoverlay $RuntimeBuildDir \stdlib\windows-vfs-overlay.yaml" ,
169
- " -g -debug-info-format=codeview" ,
170
- " -Xlinker /INCREMENTAL:NO" ,
171
- " -Xlinker /DEBUG" ,
172
- " -Xlinker /OPT:REF" ,
173
- " -Xlinker /OPT:ICF"
179
+ " -L $SwiftResourceDir \windows" ,
180
+ " -vfsoverlay $RuntimeBuildDir \stdlib\windows-vfs-overlay.yaml" ,
181
+ " -g -debug-info-format=codeview" ,
182
+ " -Xlinker /INCREMENTAL:NO" ,
183
+ " -Xlinker /DEBUG" ,
184
+ " -Xlinker /OPT:REF" ,
185
+ " -Xlinker /OPT:ICF"
174
186
) -Join " "
175
187
176
- TryAddKeyValue $Defines CMAKE_Swift_FLAGS $SwiftcFlags
188
+ Append - FlagsDefine $Defines CMAKE_Swift_FLAGS $SwiftcFlags
177
189
}
178
190
if (" " -ne $InstallTo ) {
179
- TryAddKeyValue $Defines CMAKE_INSTALL_PREFIX $InstallTo
191
+ TryAdd - Define $Defines CMAKE_INSTALL_PREFIX $InstallTo
180
192
}
181
193
182
194
# Generate the project
@@ -797,8 +809,6 @@ function Build-Certificates($Arch)
797
809
798
810
function Build-PackageManager ($Arch )
799
811
{
800
- $RuntimeBuildDir = Get-ProjectBuildDir $Arch 1
801
- $SwiftResourceDir = " ${RuntimeBuildDir} \lib\swift"
802
812
$DispatchBuildDir = Get-ProjectBuildDir $Arch 2
803
813
$FoundationBuildDir = Get-ProjectBuildDir $Arch 3
804
814
@@ -811,7 +821,7 @@ function Build-PackageManager($Arch)
811
821
- BuildDefaultTarget `
812
822
- Defines @ {
813
823
BUILD_SHARED_LIBS = " YES" ;
814
- CMAKE_Swift_FLAGS = " -DCRYPTO_v2 -resource-dir $SwiftResourceDir -L $SwiftResourceDir \windows -vfsoverlay $RuntimeBuildDir \stdlib\windows-vfs-overlay.yaml " ;
824
+ CMAKE_Swift_FLAGS = " -DCRYPTO_v2" ;
815
825
dispatch_DIR = " $DispatchBuildDir \cmake\modules" ;
816
826
Foundation_DIR = " $FoundationBuildDir \cmake\modules" ;
817
827
SwiftSystem_DIR = " $BinaryCache \2\cmake\modules" ;
@@ -841,6 +851,7 @@ function Build-IndexStoreDB($Arch)
841
851
- BuildDefaultTarget `
842
852
- Defines @ {
843
853
BUILD_SHARED_LIBS = " NO" ;
854
+ CMAKE_C_FLAGS = " -Xclang -fno-split-cold-code" ;
844
855
CMAKE_CXX_FLAGS = " -Xclang -fno-split-cold-code" ;
845
856
dispatch_DIR = " $DispatchBuildDir \cmake\modules" ;
846
857
Foundation_DIR = " $FoundationBuildDir \cmake\modules" ;
@@ -927,7 +938,7 @@ Copy-Item -Force $BinaryCache\7\bin\swift-driver.exe $ToolchainInstallRoot\usr\b
927
938
$python = " ${Env: ProgramFiles(x86)} \Microsoft Visual Studio\Shared\Python39_64\python.exe"
928
939
if (-not (Test-Path $python ))
929
940
{
930
- $python = (where.exe python) | Select - First 1
941
+ $python = (where.exe python) | Select-Object - First 1
931
942
if (-not (Test-Path $python ))
932
943
{
933
944
throw " Python.exe not found"
0 commit comments