Skip to content

Commit 93daeff

Browse files
authored
Merge pull request #83796 from compnerd/clang
build.ps1: intrduce the ability to build with clang optionally
2 parents 900be48 + af46e6c commit 93daeff

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

utils/build.ps1

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ param
170170
# Toolchain Cross-compilation
171171
[ValidateSet("AMD64", "ARM64")]
172172
[string] $HostArchName = $(if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }),
173+
[object] $UseHostToolchain = $true,
173174

174175
# Debug Information
175176
[switch] $DebugInfo,
@@ -248,6 +249,10 @@ if ($Test -contains "*") {
248249
$Test = @("lld", "lldb", "swift", "dispatch", "foundation", "xctest", "swift-format", "sourcekit-lsp")
249250
}
250251

252+
if ($UseHostToolchain -is [string]) {
253+
$UseHostToolchain = [System.Convert]::ToBoolean($UseHostToolchain)
254+
}
255+
251256
## Declare static build and build tool parameters.
252257

253258
$DefaultPinned = @{
@@ -1355,11 +1360,11 @@ function Build-CMakeProject {
13551360
[hashtable] $Platform,
13561361
[string] $Generator = "Ninja",
13571362
[string] $CacheScript = "",
1358-
[ValidateSet("ASM_MASM", "C", "CXX")]
1363+
[ValidateSet("", "ASM_MASM", "C", "CXX")]
13591364
[string[]] $UseMSVCCompilers = @(),
1360-
[ValidateSet("ASM", "C", "CXX", "Swift")]
1365+
[ValidateSet("", "ASM", "C", "CXX", "Swift")]
13611366
[string[]] $UseBuiltCompilers = @(),
1362-
[ValidateSet("ASM", "C", "CXX", "Swift")]
1367+
[ValidateSet("", "ASM", "C", "CXX", "Swift")]
13631368
[string[]] $UsePinnedCompilers = @(),
13641369
[switch] $AddAndroidCMakeEnv = $false,
13651370
[switch] $UseGNUDriver = $false,
@@ -1923,7 +1928,8 @@ function Build-CMark([Hashtable] $Platform) {
19231928
-Bin (Get-CMarkBinaryCache $Platform) `
19241929
-InstallTo "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+Asserts\usr" `
19251930
-Platform $Platform `
1926-
-UseMSVCCompilers C,CXX `
1931+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C", "CXX") } else { @("") }) `
1932+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C", "CXX") }) `
19271933
-Defines @{
19281934
BUILD_SHARED_LIBS = "YES";
19291935
BUILD_TESTING = "NO";
@@ -1936,7 +1942,8 @@ function Build-BuildTools([Hashtable] $Platform) {
19361942
-Src $SourceCache\llvm-project\llvm `
19371943
-Bin (Get-ProjectBinaryCache $Platform BuildTools) `
19381944
-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") }) `
19401947
-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 `
19411948
-Defines @{
19421949
CMAKE_CROSSCOMPILING = "NO";
@@ -2098,8 +2105,8 @@ function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
20982105
-Bin (Get-ProjectBinaryCache $Platform Compilers) `
20992106
-InstallTo "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$Variant\usr" `
21002107
-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") }) `
21032110
-SwiftSDK (Get-PinnedToolchainSDK) `
21042111
-BuildTargets @("install-distribution") `
21052112
-CacheScript $SourceCache\swift\cmake\caches\Windows-$($Platform.Architecture.LLVMName).cmake `
@@ -2166,8 +2173,8 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test
21662173
-Bin $(Get-ProjectBinaryCache $Platform Compilers) `
21672174
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
21682175
-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") }) `
21712178
-SwiftSDK (Get-PinnedToolchainSDK) `
21722179
-BuildTargets $Targets `
21732180
-CacheScript $SourceCache\swift\cmake\caches\Windows-$($Platform.Architecture.LLVMName).cmake `
@@ -2320,7 +2327,8 @@ function Build-ZLib([Hashtable] $Platform) {
23202327
-Bin "$BinaryCache\$($Platform.Triple)\zlib" `
23212328
-InstallTo "$BinaryCache\$($Platform.Triple)\usr" `
23222329
-Platform $Platform `
2323-
-UseMSVCCompilers C `
2330+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
2331+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
23242332
-Defines @{
23252333
BUILD_SHARED_LIBS = "NO";
23262334
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
@@ -2333,7 +2341,8 @@ function Build-XML2([Hashtable] $Platform) {
23332341
-Bin "$BinaryCache\$($Platform.Triple)\libxml2-2.11.5" `
23342342
-InstallTo "$BinaryCache\$($Platform.Triple)\usr" `
23352343
-Platform $Platform `
2336-
-UseMSVCCompilers C,CXX `
2344+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C", "CXX") } else { @("") }) `
2345+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C", "CXX") }) `
23372346
-Defines @{
23382347
BUILD_SHARED_LIBS = "NO";
23392348
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
@@ -2353,7 +2362,8 @@ function Build-RegsGen2([Hashtable] $Platform) {
23532362
-Bin (Get-ProjectBinaryCache $Platform RegsGen2) `
23542363
-Platform $Platform `
23552364
-BuildTargets default `
2356-
-UseMSVCCompilers C,CXX `
2365+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C", "CXX") } else { @("") }) `
2366+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C", "CXX") }) `
23572367
-Defines @{
23582368
BISON_EXECUTABLE = "$(Get-BisonExecutable)";
23592369
FLEX_EXECUTABLE = "$(Get-FlexExecutable)";
@@ -2387,7 +2397,8 @@ function Build-CURL([Hashtable] $Platform) {
23872397
-Bin "$BinaryCache\$($Platform.Triple)\curl" `
23882398
-InstallTo "$BinaryCache\$($Platform.Triple)\usr" `
23892399
-Platform $Platform `
2390-
-UseMSVCCompilers C `
2400+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
2401+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
23912402
-Defines ($PlatformDefines + @{
23922403
BUILD_SHARED_LIBS = "NO";
23932404
BUILD_TESTING = "NO";
@@ -3205,7 +3216,8 @@ function Build-SQLite([Hashtable] $Platform) {
32053216
-Src $SourceCache\swift-toolchain-sqlite `
32063217
-Bin (Get-ProjectBinaryCache $Platform SQLite) `
32073218
-Platform $Platform `
3208-
-UseMSVCCompilers C `
3219+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
3220+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
32093221
-BuildTargets default `
32103222
-Defines @{
32113223
BUILD_SHARED_LIBS = "NO";
@@ -3287,7 +3299,8 @@ function Build-LLBuild([Hashtable] $Platform) {
32873299
-Bin (Get-ProjectBinaryCache $Platform LLBuild) `
32883300
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
32893301
-Platform $Platform `
3290-
-UseMSVCCompilers CXX `
3302+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
3303+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
32913304
-UseBuiltCompilers Swift `
32923305
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
32933306
-Defines @{
@@ -3314,7 +3327,8 @@ function Test-LLBuild {
33143327
-Src $SourceCache\llbuild `
33153328
-Bin (Get-ProjectBinaryCache $BuildPlatform LLBuild) `
33163329
-Platform $Platform `
3317-
-UseMSVCCompilers CXX `
3330+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) `
3331+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) `
33183332
-UseBuiltCompilers Swift `
33193333
-SwiftSDK (Get-SwiftSDK $BuildPlatform.OS) `
33203334
-BuildTargets default,test-llbuild `
@@ -3482,7 +3496,8 @@ function Build-Format([Hashtable] $Platform) {
34823496
-Bin (Get-ProjectBinaryCache $Platform Format) `
34833497
-InstallTo "$($Platform.ToolchainInstallRoot)\usr" `
34843498
-Platform $Platform `
3485-
-UseMSVCCompilers C `
3499+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
3500+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
34863501
-UseBuiltCompilers Swift `
34873502
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
34883503
-Defines @{
@@ -3537,7 +3552,8 @@ function Build-LMDB([Hashtable] $Platform) {
35373552
-Src $SourceCache\swift-lmdb `
35383553
-Bin (Get-ProjectBinaryCache $Platform LMDB) `
35393554
-Platform $Platform `
3540-
-UseMSVCCompilers C `
3555+
-UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) `
3556+
-UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) `
35413557
-BuildTargets default
35423558
}
35433559

0 commit comments

Comments
 (0)