@@ -423,6 +423,8 @@ enum TargetComponent {
423423 Foundation
424424 XCTest
425425 Testing
426+ ClangBuiltins
427+ ClangRuntime
426428}
427429
428430function Get-TargetProjectBinaryCache ($Arch , [TargetComponent ]$Project ) {
@@ -1690,13 +1692,61 @@ function Build-LLVM([Platform]$Platform, $Arch) {
16901692 - Bin (Get-TargetProjectBinaryCache $Arch LLVM) `
16911693 - Arch $Arch `
16921694 - Platform $Platform `
1693- - UseMSVCCompilers C, CXX `
1695+ - UseBuiltCompilers C, CXX `
16941696 - Defines @ {
16951697 CMAKE_SYSTEM_NAME = $Platform.ToString ();
16961698 LLVM_HOST_TRIPLE = $Arch.LLVMTarget ;
16971699 }
16981700}
16991701
1702+ function Build-Sanitizers ([Platform ]$Platform , $Arch ) {
1703+ $LLVMTargetCache = $ (Get-TargetProjectBinaryCache $Arch LLVM)
1704+ $LITVersionStr = $ (Invoke-Program $ (Get-PythonExecutable ) " $LLVMTargetCache \bin\llvm-lit.py" -- version)
1705+ if (-not ($LITVersionStr -match " lit (\d+)\.\d+\.\d+.*" )) {
1706+ throw " Unexpected version string output from llvm-lit.py"
1707+ }
1708+ $LLVMVersionMajor = $Matches.1
1709+ $InstallTo = " $ ( $HostArch.ToolchainInstallRoot ) \usr\lib\clang\$LLVMVersionMajor "
1710+ Write-Host " Sanitizers SDK directory: $InstallTo "
1711+
1712+ Build-CMakeProject `
1713+ - Src $SourceCache \llvm- project\compiler- rt\lib\builtins `
1714+ - Bin " $ ( Get-TargetProjectBinaryCache $Arch ClangBuiltins) " `
1715+ - InstallTo $InstallTo `
1716+ - Arch $Arch `
1717+ - Platform $Platform `
1718+ - UseBuiltCompilers ASM, C, CXX `
1719+ - BuildTargets " install-compiler-rt" `
1720+ - Defines (@ {
1721+ CMAKE_SYSTEM_NAME = $Platform.ToString ();
1722+ LLVM_DIR = " $LLVMTargetCache \lib\cmake\llvm" ;
1723+ LLVM_ENABLE_PER_TARGET_RUNTIME_DIR = " YES" ;
1724+ COMPILER_RT_DEFAULT_TARGET_ONLY = " YES" ;
1725+ })
1726+
1727+ Build-CMakeProject `
1728+ - Src $SourceCache \llvm- project\compiler- rt `
1729+ - Bin " $ ( Get-TargetProjectBinaryCache $Arch ClangRuntime) " `
1730+ - InstallTo $InstallTo `
1731+ - Arch $Arch `
1732+ - Platform $Platform `
1733+ - UseBuiltCompilers ASM, C, CXX `
1734+ - BuildTargets " install-compiler-rt" `
1735+ - Defines (@ {
1736+ CMAKE_SYSTEM_NAME = $Platform.ToString ();
1737+ LLVM_DIR = " $LLVMTargetCache \lib\cmake\llvm" ;
1738+ LLVM_ENABLE_PER_TARGET_RUNTIME_DIR = " YES" ;
1739+ COMPILER_RT_DEFAULT_TARGET_ONLY = " YES" ;
1740+ COMPILER_RT_BUILD_BUILTINS = " NO" ;
1741+ COMPILER_RT_BUILD_CRT = " NO" ;
1742+ COMPILER_RT_BUILD_LIBFUZZER = " NO" ;
1743+ COMPILER_RT_BUILD_ORC = " NO" ;
1744+ COMPILER_RT_BUILD_XRAY = " NO" ;
1745+ COMPILER_RT_BUILD_PROFILE = " YES" ;
1746+ COMPILER_RT_BUILD_SANITIZERS = " YES" ;
1747+ })
1748+ }
1749+
17001750function Build-ZLib ([Platform ]$Platform , $Arch ) {
17011751 $ArchName = $Arch.LLVMName
17021752
@@ -2919,6 +2969,7 @@ if (-not $SkipBuild) {
29192969 Invoke-BuildStep Build-FoundationMacros - Build Windows $BuildArch
29202970 Invoke-BuildStep Build-TestingMacros - Build Windows $BuildArch
29212971 Invoke-BuildStep Build-Foundation Windows $Arch
2972+ Invoke-BuildStep Build-Sanitizers Windows $Arch
29222973 Invoke-BuildStep Build-XCTest Windows $Arch
29232974 Invoke-BuildStep Build-Testing Windows $Arch
29242975 Invoke-BuildStep Write-SDKSettingsPlist Windows $Arch
@@ -2938,6 +2989,7 @@ if (-not $SkipBuild) {
29382989 Invoke-BuildStep Build-Runtime Android $Arch
29392990 Invoke-BuildStep Build-Dispatch Android $Arch
29402991 Invoke-BuildStep Build-Foundation Android $Arch
2992+ Invoke-BuildStep Build-Sanitizers Android $Arch
29412993 Invoke-BuildStep Build-XCTest Android $Arch
29422994 Invoke-BuildStep Build-Testing Android $Arch
29432995 Invoke-BuildStep Write-SDKSettingsPlist Android $Arch
0 commit comments