@@ -201,6 +201,8 @@ param
201201 [string []] $Test = @ (),
202202
203203 [switch ] $IncludeDS2 = $false ,
204+ [ValidateSet (" none" , " full" , " thin" )]
205+ [string ] $LTO = " none" ,
204206 [switch ] $IncludeNoAsserts = $false ,
205207 [ValidateSet (" debug" , " release" )]
206208 [string ] $FoundationTestConfiguration = " debug" ,
@@ -2055,6 +2057,10 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
20552057 $SwiftFlags += @ (" -Xcc" , " -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH" );
20562058 }
20572059
2060+ if ($LTO -ne " none" ) {
2061+ $SwiftFlags += @ (" -use-ld=lld" );
2062+ }
2063+
20582064 return $TestDefines + $DebugDefines + @ {
20592065 CLANG_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " clang-tblgen.exe" );
20602066 CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path - Path $BuildTools - ChildPath " clang-tidy-confusable-chars-gen.exe" );
@@ -2068,6 +2074,17 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
20682074 LLDB_TEST_MAKE = " $BinaryCache \GnuWin32Make-4.4.1\bin\make.exe" ;
20692075 LLVM_CONFIG_PATH = (Join-Path - Path $BuildTools - ChildPath " llvm-config.exe" );
20702076 LLVM_ENABLE_ASSERTIONS = $ (if ($Variant -eq " Asserts" ) { " YES" } else { " NO" })
2077+ LLVM_ENABLE_LTO = $ (switch ($LTO ) {
2078+ " none" { " OFF" }
2079+ default {
2080+ if ($UseHostToolchain ) { throw " LTO is not supported with the host toolchain" }
2081+ " $LTO "
2082+ }
2083+ })
2084+ LLVM_ENABLE_LLD = $ (switch ($LTO ) {
2085+ " none" { " NO" }
2086+ default { " YES" }
2087+ })
20712088 LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
20722089 LLVM_HOST_TRIPLE = $Platform.Triple ;
20732090 LLVM_NATIVE_TOOL_DIR = $BuildTools ;
0 commit comments