Skip to content

Commit 1857d1c

Browse files
Initial patch for early feedback
1 parent ad70dc8 commit 1857d1c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

cmake/caches/Windows-x86_64.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ endif()
4040
# The builtin targets are used to build the compiler-rt builtins.
4141
set(LLVM_BUILTIN_TARGETS ${DEFAULT_BUILTIN_TARGETS} CACHE STRING "")
4242

43-
# The runtime targets are used to build the compiler-rt profile library.
43+
# The runtime targets are used to build the profile and sanitizer libs from compiler-rt.
4444
set(LLVM_RUNTIME_TARGETS
4545
x86_64-unknown-windows-msvc
4646
aarch64-unknown-windows-msvc
@@ -58,8 +58,10 @@ foreach(target ${LLVM_RUNTIME_TARGETS})
5858
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
5959
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC NO CACHE BOOL "")
6060
set(RUNTIMES_${target}_COMPILER_RT_BUILD_PROFILE YES CACHE BOOL "")
61-
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
6261
set(RUNTIMES_${target}_COMPILER_RT_BUILD_XRAY NO CACHE BOOL "")
62+
# Sanitizers will be configured, but not built. We have separate build
63+
# steps for that, because we need a different shell for each target.
64+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_SANITIZERS NO CACHE BOOL "")
6365
endforeach()
6466

6567
foreach(target ${LLVM_BUILTIN_TARGETS})

utils/build.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ If no such Windows SDK is installed, it will be downloaded from nuget.
6666
Include the ds2 remote debug server in the SDK.
6767
This component is currently only supported in Android builds.
6868
69+
.PARAMETER IncludeSanitizers
70+
If set, include ASAN and UBSAN artifacts in the toolchain.
71+
6972
.PARAMETER SkipBuild
7073
If set, does not run the build phase.
7174
@@ -1764,6 +1767,21 @@ function Build-CURL([Platform]$Platform, $Arch) {
17641767
})
17651768
}
17661769

1770+
function Build-Sanitizers([Platform]$Platform, $Arch, $InstallTo) {
1771+
Isolate-EnvVars {
1772+
# Use configured compilers
1773+
Build-CMakeProject `
1774+
-Src $SourceCache\llvm-project\runtimes `
1775+
-Bin "$(Get-HostProjectBinaryCache Compilers)\runtimes\runtimes-$($Arch.LLVMTarget)-bins" `
1776+
-InstallTo $InstallTo `
1777+
-Arch $Arch `
1778+
-Platform $Platform `
1779+
-Defines (@{
1780+
COMPILER_RT_BUILD_SANITIZERS = "YES"
1781+
})
1782+
}
1783+
}
1784+
17671785
function Build-Runtime([Platform]$Platform, $Arch) {
17681786
$PlatformDefines = @{}
17691787
if ($Platform -eq "Android") {
@@ -2756,6 +2774,11 @@ if (-not $SkipBuild) {
27562774

27572775
Invoke-BuildStep Build-CMark $HostArch
27582776
Invoke-BuildStep Build-Compilers $HostArch
2777+
if ($IncludeSanitizers) {
2778+
$InstallTo = "$($HostArch.ToolchainInstallRoot)\usr"
2779+
Invoke-BuildStep Build-Sanitizers Windows $ArchX64 $InstallTo
2780+
Invoke-BuildStep Build-Sanitizers Windows $ArchARM64 $InstallTo
2781+
}
27592782
}
27602783

27612784
if ($Clean) {

0 commit comments

Comments
 (0)