From 8e8055e680d2071e71bd17d055cd5029d7ac5f12 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Thu, 16 Oct 2025 15:51:53 -0700 Subject: [PATCH] Add CAS support --- utils/build.ps1 | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 8d49c02efd281..3c4b6585c7364 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -158,6 +158,10 @@ param [ValidatePattern('^\d+(\.\d+)*$')] [string] $SCCacheVersion = "0.10.0", + # Build with CAS + [switch] $EnableCAS = $false, + [string] $CASPath = "S:\cas", + # SBoM Support [switch] $IncludeSBoM = $false, [string] $SyftVersion = "1.29.1", @@ -560,6 +564,10 @@ if (-not $PinnedBuild) { $PinnedToolchain = [IO.Path]::GetFileNameWithoutExtension($PinnedBuild) +if ($EnableCAS -and ($UseHostToolchain -or ($PinnedVersion -ne "0.0.0"))) { + throw "CAS currently requires using a main-branch pinned toolchain." +} + $HostPlatform = switch ($HostArchName) { "AMD64" { $KnownPlatforms[$HostOS.ToString() + "X64"] } "ARM64" { $KnownPlatforms[$HostOS.ToString() + "ARM64"] } @@ -1569,6 +1577,14 @@ function Build-CMakeProject { @("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline") } + if ($EnableCAS -and $UsePinnedCompilers.Contains("C")) { + $CFLAGS += if ($UseGNUDriver) { + @("-fdepscan=inline", "-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath) + } else { + @("/clang:-fdepscan=inline", "/clang:-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath) + } + } + if ($DebugInfo) { if ($UsePinnedCompilers.Contains("C") -or $UseBuiltCompilers.Contains("C")) { if ($CDebugFormat -eq "dwarf") { @@ -1609,6 +1625,14 @@ function Build-CMakeProject { @("/GS-", "/Gw", "/Gy", "/Oy", "/Oi", "/Zc:inline", "/Zc:__cplusplus") } + if ($EnableCAS -and $UsePinnedCompilers.Contains("CXX")) { + $CXXFLAGS += if ($UseGNUDriver) { + @("-fdepscan=inline", "-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath) + } else { + @("/clang:-fdepscan=inline", "/clang:-fdepscan-include-tree", "-Xclang", "-fcas-path", "-Xclang", $CASPath) + } + } + if ($DebugInfo) { if ($UsePinnedCompilers.Contains("CXX") -or $UseBuiltCompilers.Contains("CXX")) { if ($CDebugFormat -eq "dwarf") { @@ -2156,6 +2180,12 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] $SwiftFlags += @("-use-ld=lld"); } + $CMakeStaticLibPrefixSwiftDefine = if ((Get-PinnedToolchainVersion) -eq "0.0.0") { + @{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; } + } else { + @{} + } + return $TestDefines + $DebugDefines + @{ CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe"); CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe"); @@ -2207,7 +2237,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] SWIFT_STDLIB_ASSERTIONS = "NO"; SWIFTSYNTAX_ENABLE_ASSERTIONS = "NO"; "cmark-gfm_DIR" = "$($Platform.ToolchainInstallRoot)\usr\lib\cmake"; - } + } + $CMakeStaticLibPrefixSwiftDefine } function Build-Compilers([Hashtable] $Platform, [string] $Variant) {