@@ -829,11 +829,16 @@ function Fetch-Dependencies {
829829 }
830830}
831831
832- function Get-PinnedToolchainTool () {
832+ function Get-PinnedToolchainTool ([ string ] $Name ) {
833833 if (Test-Path " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin" ) {
834- return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
834+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
835+ } else {
836+ $Path = " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
837+ }
838+ if ($Name ) {
839+ $Path = " $Path \$Name "
835840 }
836- return " $BinaryCache \toolchains\ ${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin "
841+ return $Path
837842}
838843
839844function Get-PinnedToolchainSDK () {
@@ -864,6 +869,10 @@ $CompilersBinaryCache = if ($IsCrossCompiling) {
864869 Get-HostProjectBinaryCache Compilers
865870}
866871
872+ function Get-BuiltToolchainTool ([string ] $Name ) {
873+ return if ($Name ) { " $CompilersBinaryCache \bin\$Name " } else { " $CompilersBinaryCache \bin" }
874+ }
875+
867876function Get-ClangDriverName ([Platform ] $Platform , [string ] $Lang ) {
868877 switch ($Platform ) {
869878 Windows {
@@ -1032,7 +1041,7 @@ function Build-CMakeProject {
10321041 # Use a built lld linker as the Android's NDK linker might be too
10331042 # old and not support all required relocations needed by the Swift
10341043 # runtime.
1035- $ldPath = ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " ld.lld" ) )
1044+ $ldPath = (Get-BuiltToolchainTool " ld.lld" )
10361045 Append- FlagsDefine $Defines CMAKE_SHARED_LINKER_FLAGS " --ld-path=$ldPath "
10371046 Append- FlagsDefine $Defines CMAKE_EXE_LINKER_FLAGS " --ld-path=$ldPath "
10381047 }
@@ -1055,9 +1064,9 @@ function Build-CMakeProject {
10551064 if ($UsePinnedCompilers.Contains (" ASM" ) -Or $UseBuiltCompilers.Contains (" ASM" )) {
10561065 $Driver = (Get-ClangDriverName $Platform - Lang " ASM" )
10571066 if ($UseBuiltCompilers.Contains (" ASM" )) {
1058- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1067+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-BuiltToolchainTool $Driver )
10591068 } else {
1060- TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1069+ TryAdd- KeyValue $Defines CMAKE_ASM_COMPILER (Get-PinnedToolchainTool $Driver )
10611070 }
10621071 Append- FlagsDefine $Defines CMAKE_ASM_FLAGS " --target=$ ( $Arch.LLVMTarget ) "
10631072 if ($Platform -eq " Windows" ) {
@@ -1067,9 +1076,9 @@ function Build-CMakeProject {
10671076 if ($UsePinnedCompilers.Contains (" C" ) -Or $UseBuiltCompilers.Contains (" C" )) {
10681077 $Driver = (Get-ClangDriverName $Platform - Lang " C" )
10691078 if ($UseBuiltCompilers.Contains (" C" )) {
1070- TryAdd- KeyValue $Defines CMAKE_C_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1079+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-BuiltToolchainTool $Driver )
10711080 } else {
1072- TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1081+ TryAdd- KeyValue $Defines CMAKE_C_COMPILER (Get-PinnedToolchainTool $Driver )
10731082 }
10741083 TryAdd- KeyValue $Defines CMAKE_C_COMPILER_TARGET $Arch.LLVMTarget
10751084
@@ -1086,9 +1095,9 @@ function Build-CMakeProject {
10861095 if ($UsePinnedCompilers.Contains (" CXX" ) -Or $UseBuiltCompilers.Contains (" CXX" )) {
10871096 $Driver = (Get-ClangDriverName $Platform - Lang " CXX" )
10881097 if ($UseBuiltCompilers.Contains (" CXX" )) {
1089- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , $Driver ) )
1098+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-BuiltToolchainTool $Driver )
10901099 } else {
1091- TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath $Driver )
1100+ TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER (Get-PinnedToolchainTool $Driver )
10921101 }
10931102 TryAdd- KeyValue $Defines CMAKE_CXX_COMPILER_TARGET $Arch.LLVMTarget
10941103
@@ -1108,9 +1117,9 @@ function Build-CMakeProject {
11081117 if ($UseSwiftSwiftDriver ) {
11091118 TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([IO.Path ]::Combine($DriverBinaryCache , " bin" , " swiftc.exe" ))
11101119 } elseif ($UseBuiltCompilers.Contains (" Swift" )) {
1111- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER ([ IO.Path ]::Combine( $CompilersBinaryCache , " bin " , " swiftc.exe" ) )
1120+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-BuiltToolchainTool " swiftc.exe" )
11121121 } else {
1113- TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Join-Path - Path ( Get-PinnedToolchainTool ) - ChildPath " swiftc.exe" )
1122+ TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER (Get-PinnedToolchainTool " swiftc.exe" )
11141123 }
11151124 if (-not ($Platform -eq " Windows" )) {
11161125 TryAdd- KeyValue $Defines CMAKE_Swift_COMPILER_WORKS = " YES"
0 commit comments