Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ param
[ValidatePattern('^\d+(\.\d+)*$')]
[string] $SCCacheVersion = "0.10.0",

# Build with CAS
[switch] $EnableCAS = $false,
[string] $CASPath = "S:\cas",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ImageRoot rather than S:. The swift.org CI uses a different root (T:).

I wonder if we should just make this a required parameter from the user.


# SBoM Support
[switch] $IncludeSBoM = $false,
[string] $SyftVersion = "1.29.1",
Expand Down Expand Up @@ -560,6 +564,10 @@ if (-not $PinnedBuild) {

$PinnedToolchain = [IO.Path]::GetFileNameWithoutExtension($PinnedBuild)

if ($EnableCAS -and ($UseHostToolchain -or ($PinnedVersion -ne "0.0.0"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. would not it be better to check llvm version instead llvm-project/llvm/utils/lit.py --version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This intends to check for a swift main-branch build which is currently the only swift build/repo where it currently works and so it's more about the swift version than the LLVM version

throw "CAS currently requires using a main-branch pinned toolchain."
}

$HostPlatform = switch ($HostArchName) {
"AMD64" { $KnownPlatforms[$HostOS.ToString() + "X64"] }
"ARM64" { $KnownPlatforms[$HostOS.ToString() + "ARM64"] }
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down