@@ -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 = @ {
@@ -1355,11 +1360,11 @@ function Build-CMakeProject {
1355
1360
[hashtable ] $Platform ,
1356
1361
[string ] $Generator = " Ninja" ,
1357
1362
[string ] $CacheScript = " " ,
1358
- [ValidateSet (" ASM_MASM" , " C" , " CXX" )]
1363
+ [ValidateSet (" " , " ASM_MASM" , " C" , " CXX" )]
1359
1364
[string []] $UseMSVCCompilers = @ (),
1360
- [ValidateSet (" ASM" , " C" , " CXX" , " Swift" )]
1365
+ [ValidateSet (" " , " ASM" , " C" , " CXX" , " Swift" )]
1361
1366
[string []] $UseBuiltCompilers = @ (),
1362
- [ValidateSet (" ASM" , " C" , " CXX" , " Swift" )]
1367
+ [ValidateSet (" " , " ASM" , " C" , " CXX" , " Swift" )]
1363
1368
[string []] $UsePinnedCompilers = @ (),
1364
1369
[switch ] $AddAndroidCMakeEnv = $false ,
1365
1370
[switch ] $UseGNUDriver = $false ,
@@ -1923,7 +1928,8 @@ function Build-CMark([Hashtable] $Platform) {
1923
1928
- Bin (Get-CMarkBinaryCache $Platform ) `
1924
1929
- InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts\usr" `
1925
1930
- Platform $Platform `
1926
- - UseMSVCCompilers C, CXX `
1931
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
1932
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
1927
1933
- Defines @ {
1928
1934
BUILD_SHARED_LIBS = " YES" ;
1929
1935
BUILD_TESTING = " NO" ;
@@ -1936,7 +1942,8 @@ function Build-BuildTools([Hashtable] $Platform) {
1936
1942
- Src $SourceCache \llvm- project\llvm `
1937
1943
- Bin (Get-ProjectBinaryCache $Platform BuildTools) `
1938
1944
- Platform $Platform `
1939
- - UseMSVCCompilers ASM_MASM, C, CXX `
1945
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" ASM_MASM" , " C" , " CXX" ) } else { @ (" " ) }) `
1946
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" ASM" , " C" , " CXX" ) }) `
1940
1947
- 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 `
1941
1948
- Defines @ {
1942
1949
CMAKE_CROSSCOMPILING = " NO" ;
@@ -2098,8 +2105,8 @@ function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
2098
2105
- Bin (Get-ProjectBinaryCache $Platform Compilers) `
2099
2106
- InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr" `
2100
2107
- Platform $Platform `
2101
- - UseMSVCCompilers C , CXX `
2102
- - UsePinnedCompilers Swift `
2108
+ - UseMSVCCompilers $ ( if ( $UseHostToolchain ) { @ ( " C " , " CXX" ) } else { @ ( " " ) }) `
2109
+ - UsePinnedCompilers $ ( if ( $UseHostToolchain ) { @ ( " Swift" ) } else { @ ( " C " , " CXX " , " Swift " ) }) `
2103
2110
- SwiftSDK (Get-PinnedToolchainSDK ) `
2104
2111
- BuildTargets @ (" install-distribution" ) `
2105
2112
- CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
@@ -2166,8 +2173,8 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
2166
2173
- Bin $ (Get-ProjectBinaryCache $Platform Compilers) `
2167
2174
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
2168
2175
- Platform $Platform `
2169
- - UseMSVCCompilers C , CXX `
2170
- - UsePinnedCompilers Swift `
2176
+ - UseMSVCCompilers $ ( if ( $UseHostToolchain ) { @ ( " C " , " CXX" ) } else { @ ( " " ) }) `
2177
+ - UsePinnedCompilers $ ( if ( $UseHostToolchain ) { @ ( " Swift" ) } else { @ ( " C " , " CXX " , " Swift " ) }) `
2171
2178
- SwiftSDK (Get-PinnedToolchainSDK ) `
2172
2179
- BuildTargets $Targets `
2173
2180
- CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
@@ -2320,7 +2327,8 @@ function Build-ZLib([Hashtable] $Platform) {
2320
2327
- Bin " $BinaryCache \$ ( $Platform.Triple ) \zlib" `
2321
2328
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2322
2329
- Platform $Platform `
2323
- - UseMSVCCompilers C `
2330
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
2331
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
2324
2332
- Defines @ {
2325
2333
BUILD_SHARED_LIBS = " NO" ;
2326
2334
CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
@@ -2333,7 +2341,8 @@ function Build-XML2([Hashtable] $Platform) {
2333
2341
- Bin " $BinaryCache \$ ( $Platform.Triple ) \libxml2-2.11.5" `
2334
2342
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2335
2343
- Platform $Platform `
2336
- - UseMSVCCompilers C, CXX `
2344
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
2345
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
2337
2346
- Defines @ {
2338
2347
BUILD_SHARED_LIBS = " NO" ;
2339
2348
CMAKE_POSITION_INDEPENDENT_CODE = " YES" ;
@@ -2353,7 +2362,8 @@ function Build-RegsGen2([Hashtable] $Platform) {
2353
2362
- Bin (Get-ProjectBinaryCache $Platform RegsGen2) `
2354
2363
- Platform $Platform `
2355
2364
- BuildTargets default `
2356
- - UseMSVCCompilers C, CXX `
2365
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" , " CXX" ) } else { @ (" " ) }) `
2366
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" , " CXX" ) }) `
2357
2367
- Defines @ {
2358
2368
BISON_EXECUTABLE = " $ ( Get-BisonExecutable ) " ;
2359
2369
FLEX_EXECUTABLE = " $ ( Get-FlexExecutable ) " ;
@@ -2387,7 +2397,8 @@ function Build-CURL([Hashtable] $Platform) {
2387
2397
- Bin " $BinaryCache \$ ( $Platform.Triple ) \curl" `
2388
2398
- InstallTo " $BinaryCache \$ ( $Platform.Triple ) \usr" `
2389
2399
- Platform $Platform `
2390
- - UseMSVCCompilers C `
2400
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
2401
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
2391
2402
- Defines ($PlatformDefines + @ {
2392
2403
BUILD_SHARED_LIBS = " NO" ;
2393
2404
BUILD_TESTING = " NO" ;
@@ -3205,7 +3216,8 @@ function Build-SQLite([Hashtable] $Platform) {
3205
3216
- Src $SourceCache \swift- toolchain- sqlite `
3206
3217
- Bin (Get-ProjectBinaryCache $Platform SQLite) `
3207
3218
- Platform $Platform `
3208
- - UseMSVCCompilers C `
3219
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3220
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3209
3221
- BuildTargets default `
3210
3222
- Defines @ {
3211
3223
BUILD_SHARED_LIBS = " NO" ;
@@ -3287,7 +3299,8 @@ function Build-LLBuild([Hashtable] $Platform) {
3287
3299
- Bin (Get-ProjectBinaryCache $Platform LLBuild) `
3288
3300
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
3289
3301
- Platform $Platform `
3290
- - UseMSVCCompilers CXX `
3302
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" CXX" ) } else { @ (" " ) }) `
3303
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" CXX" ) }) `
3291
3304
- UseBuiltCompilers Swift `
3292
3305
- SwiftSDK (Get-SwiftSDK $Platform.OS ) `
3293
3306
- Defines @ {
@@ -3314,7 +3327,8 @@ function Test-LLBuild {
3314
3327
- Src $SourceCache \llbuild `
3315
3328
- Bin (Get-ProjectBinaryCache $BuildPlatform LLBuild) `
3316
3329
- Platform $Platform `
3317
- - UseMSVCCompilers CXX `
3330
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" CXX" ) } else { @ (" " ) }) `
3331
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" CXX" ) }) `
3318
3332
- UseBuiltCompilers Swift `
3319
3333
- SwiftSDK (Get-SwiftSDK $BuildPlatform.OS ) `
3320
3334
- BuildTargets default , test-llbuild `
@@ -3482,7 +3496,8 @@ function Build-Format([Hashtable] $Platform) {
3482
3496
- Bin (Get-ProjectBinaryCache $Platform Format) `
3483
3497
- InstallTo " $ ( $Platform.ToolchainInstallRoot ) \usr" `
3484
3498
- Platform $Platform `
3485
- - UseMSVCCompilers C `
3499
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3500
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3486
3501
- UseBuiltCompilers Swift `
3487
3502
- SwiftSDK (Get-SwiftSDK $Platform.OS ) `
3488
3503
- Defines @ {
@@ -3537,7 +3552,8 @@ function Build-LMDB([Hashtable] $Platform) {
3537
3552
- Src $SourceCache \swift- lmdb `
3538
3553
- Bin (Get-ProjectBinaryCache $Platform LMDB) `
3539
3554
- Platform $Platform `
3540
- - UseMSVCCompilers C `
3555
+ - UseMSVCCompilers $ (if ($UseHostToolchain ) { @ (" C" ) } else { @ (" " ) }) `
3556
+ - UsePinnedCompilers $ (if ($UseHostToolchain ) { @ (" " ) } else { @ (" C" ) }) `
3541
3557
- BuildTargets default
3542
3558
}
3543
3559
0 commit comments