@@ -170,6 +170,7 @@ param
170
170
# Toolchain Cross-compilation
171
171
[ValidateSet (" AMD64" , " ARM64" )]
172
172
[string ] $HostArchName = $ (if ($env: PROCESSOR_ARCHITEW6432 ) { $env: PROCESSOR_ARCHITEW6432 } else { $env: PROCESSOR_ARCHITECTURE }),
173
+ [object ] $UseHostToolchain = $true ,
173
174
174
175
# Debug Information
175
176
[switch ] $DebugInfo ,
@@ -248,6 +249,10 @@ if ($Test -contains "*") {
248
249
$Test = @ (" lld" , " lldb" , " swift" , " dispatch" , " foundation" , " xctest" , " swift-format" , " sourcekit-lsp" )
249
250
}
250
251
252
+ if ($UseHostToolchain -is [string ]) {
253
+ $UseHostToolchain = [System.Convert ]::ToBoolean($UseHostToolchain )
254
+ }
255
+
251
256
# # Declare static build and build tool parameters.
252
257
253
258
$DefaultPinned = @ {
@@ -1345,11 +1350,11 @@ function Build-CMakeProject {
1345
1350
[hashtable ] $Platform ,
1346
1351
[string ] $Generator = " Ninja" ,
1347
1352
[string ] $CacheScript = " " ,
1348
- [ValidateSet (" ASM_MASM" , " C" , " CXX" )]
1353
+ [ValidateSet (" " , " ASM_MASM" , " C" , " CXX" )]
1349
1354
[string []] $UseMSVCCompilers = @ (),
1350
- [ValidateSet (" ASM" , " C" , " CXX" , " Swift" )]
1355
+ [ValidateSet (" " , " ASM" , " C" , " CXX" , " Swift" )]
1351
1356
[string []] $UseBuiltCompilers = @ (),
1352
- [ValidateSet (" ASM" , " C" , " CXX" , " Swift" )]
1357
+ [ValidateSet (" " , " ASM" , " C" , " CXX" , " Swift" )]
1353
1358
[string []] $UsePinnedCompilers = @ (),
1354
1359
[switch ] $AddAndroidCMakeEnv = $false ,
1355
1360
[switch ] $UseGNUDriver = $false ,
@@ -1913,7 +1918,8 @@ function Build-CMark([Hashtable] $Platform) {
1913
1918
- Bin (Get-CMarkBinaryCache $Platform ) `
1914
1919
- InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts\usr" `
1915
1920
- Platform $Platform `
1916
- - UseMSVCCompilers C, CXX `
1921
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
1922
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
1917
1923
- Defines @ {
1918
1924
BUILD_SHARED_LIBS = " YES" ;
1919
1925
BUILD_TESTING = " NO" ;
@@ -1926,7 +1932,8 @@ function Build-BuildTools([Hashtable] $Platform) {
1926
1932
- Src $SourceCache \llvm- project\llvm `
1927
1933
- Bin (Get-ProjectBinaryCache $Platform BuildTools) `
1928
1934
- Platform $Platform `
1929
- - UseMSVCCompilers ASM_MASM, C, CXX `
1935
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" ASM_MASM" , " C" , " CXX" ) } else { @ (" " ) }) `
1936
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" ASM" , " C" , " CXX" ) }) `
1930
1937
- BuildTargets llvm- tblgen, clang- tblgen, clang- pseudo- gen, clang- tidy- confusable- chars- gen, lldb- tblgen, llvm- config, swift- def- to- strings- converter, swift- serialize- diagnostics, swift- compatibility- symbols `
1931
1938
- Defines @ {
1932
1939
CMAKE_CROSSCOMPILING = " NO" ;
@@ -2088,8 +2095,8 @@ function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
2088
2095
- Bin (Get-ProjectBinaryCache $Platform Compilers) `
2089
2096
- InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr" `
2090
2097
- Platform $Platform `
2091
- - UseMSVCCompilers C , CXX `
2092
- - UsePinnedCompilers Swift `
2098
+ - UseMSVCCompilers $ ( if ( $UseHostToolchain ) { @ ( " C " , " CXX" ) } else { @ ( " " ) }) `
2099
+ - UsePinnedCompilers $ ( if ( $UseHostToolchain ) { @ ( " Swift" ) } else { @ ( " C " , " CXX " , " Swift " ) }) `
2093
2100
- SwiftSDK (Get-PinnedToolchainSDK ) `
2094
2101
- BuildTargets @ (" install-distribution" ) `
2095
2102
- CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
@@ -2156,8 +2163,8 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
2156
2163
- Bin $ (Get-ProjectBinaryCache $Platform Compilers) `
2157
2164
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
2158
2165
- Platform $Platform `
2159
- - UseMSVCCompilers C , CXX `
2160
- - UsePinnedCompilers Swift `
2166
+ - UseMSVCCompilers $ ( if ( $UseHostToolchain ) { @ ( " C " , " CXX" ) } else { @ ( " " ) }) `
2167
+ - UsePinnedCompilers $ ( if ( $UseHostToolchain ) { @ ( " Swift" ) } else { @ ( " C " , " CXX " , " Swift " ) }) `
2161
2168
- SwiftSDK (Get-PinnedToolchainSDK ) `
2162
2169
- BuildTargets $Targets `
2163
2170
- CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
@@ -2310,7 +2317,8 @@ function Build-ZLib([Hashtable] $Platform) {
2310
2317
- Bin " $BinaryCache \$ ( $Platform.Triple ) \zlib" `
2311
2318
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2312
2319
- Platform $Platform `
2313
- - UseMSVCCompilers C `
2320
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
2321
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
2314
2322
- Defines @ {
2315
2323
BUILD_SHARED_LIBS = " NO" ;
2316
2324
CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
@@ -2323,7 +2331,8 @@ function Build-XML2([Hashtable] $Platform) {
2323
2331
- Bin " $BinaryCache \$ ( $Platform.Triple ) \libxml2-2.11.5" `
2324
2332
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2325
2333
- Platform $Platform `
2326
- - UseMSVCCompilers C, CXX `
2334
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
2335
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
2327
2336
- Defines @ {
2328
2337
BUILD_SHARED_LIBS = " NO" ;
2329
2338
CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
@@ -2343,7 +2352,8 @@ function Build-RegsGen2([Hashtable] $Platform) {
2343
2352
- Bin (Get-ProjectBinaryCache $Platform RegsGen2) `
2344
2353
- Platform $Platform `
2345
2354
- BuildTargets default `
2346
- - UseMSVCCompilers C, CXX `
2355
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
2356
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
2347
2357
- Defines @ {
2348
2358
BISON_EXECUTABLE = " $ ( Get-BisonExecutable ) " ;
2349
2359
FLEX_EXECUTABLE = " $ ( Get-FlexExecutable ) " ;
@@ -2377,7 +2387,8 @@ function Build-CURL([Hashtable] $Platform) {
2377
2387
- Bin " $BinaryCache \$ ( $Platform.Triple ) \curl" `
2378
2388
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2379
2389
- Platform $Platform `
2380
- - UseMSVCCompilers C `
2390
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
2391
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
2381
2392
- Defines ($PlatformDefines + @ {
2382
2393
BUILD_SHARED_LIBS = " NO" ;
2383
2394
BUILD_TESTING = " NO" ;
@@ -3100,7 +3111,8 @@ function Build-SQLite([Hashtable] $Platform) {
3100
3111
- Src $SourceCache \swift- toolchain- sqlite `
3101
3112
- Bin (Get-ProjectBinaryCache $Platform SQLite) `
3102
3113
- Platform $Platform `
3103
- - UseMSVCCompilers C `
3114
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3115
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3104
3116
- BuildTargets default `
3105
3117
- Defines @ {
3106
3118
BUILD_SHARED_LIBS = " NO" ;
@@ -3182,7 +3194,8 @@ function Build-LLBuild([Hashtable] $Platform) {
3182
3194
- Bin (Get-ProjectBinaryCache $Platform LLBuild) `
3183
3195
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
3184
3196
- Platform $Platform `
3185
- - UseMSVCCompilers CXX `
3197
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" CXX" ) } else { @ (" " ) }) `
3198
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" CXX" ) }) `
3186
3199
- UseBuiltCompilers Swift `
3187
3200
- SwiftSDK (Get-SwiftSDK $Platform.OS ) `
3188
3201
- Defines @ {
@@ -3209,7 +3222,8 @@ function Test-LLBuild {
3209
3222
- Src $SourceCache \llbuild `
3210
3223
- Bin (Get-ProjectBinaryCache $BuildPlatform LLBuild) `
3211
3224
- Platform $Platform `
3212
- - UseMSVCCompilers CXX `
3225
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" CXX" ) } else { @ (" " ) }) `
3226
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" CXX" ) }) `
3213
3227
- UseBuiltCompilers Swift `
3214
3228
- SwiftSDK (Get-SwiftSDK $BuildPlatform.OS ) `
3215
3229
- BuildTargets default , test-llbuild `
@@ -3377,7 +3391,8 @@ function Build-Format([Hashtable] $Platform) {
3377
3391
- Bin (Get-ProjectBinaryCache $Platform Format) `
3378
3392
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
3379
3393
- Platform $Platform `
3380
- - UseMSVCCompilers C `
3394
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3395
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3381
3396
- UseBuiltCompilers Swift `
3382
3397
- SwiftSDK (Get-SwiftSDK $Platform.OS ) `
3383
3398
- Defines @ {
@@ -3432,7 +3447,8 @@ function Build-LMDB([Hashtable] $Platform) {
3432
3447
- Src $SourceCache \swift- lmdb `
3433
3448
- Bin (Get-ProjectBinaryCache $Platform LMDB) `
3434
3449
- Platform $Platform `
3435
- - UseMSVCCompilers C `
3450
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3451
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3436
3452
- BuildTargets default
3437
3453
}
3438
3454
0 commit comments