File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -791,6 +791,9 @@ public class SwiftTool {
791
791
// Create custom toolchain if present.
792
792
if let customDestination = self . options. customCompileDestination {
793
793
destination = try Destination ( fromFile: customDestination)
794
+ } else if let target = self . options. customCompileTriple,
795
+ let targetDestination = Destination . defaultDestination ( for: target, host: hostDestination) {
796
+ destination = targetDestination
794
797
} else {
795
798
// Otherwise use the host toolchain.
796
799
destination = hostDestination
@@ -807,18 +810,6 @@ public class SwiftTool {
807
810
}
808
811
if let sdk = self . options. customCompileSDK {
809
812
destination. sdk = sdk
810
- } else if let target = destination. target, target. isWASI ( ) {
811
- // Set default SDK path when target is WASI whose SDK is embeded
812
- // in Swift toolchain
813
- do {
814
- let compilers = try UserToolchain . determineSwiftCompilers ( binDir: destination. binDir)
815
- destination. sdk = compilers. compile
816
- . parentDirectory // bin
817
- . parentDirectory // usr
818
- . appending ( components: " share " , " wasi-sysroot " )
819
- } catch {
820
- return . failure( error)
821
- }
822
813
}
823
814
destination. archs = options. archs
824
815
Original file line number Diff line number Diff line change @@ -178,6 +178,24 @@ public struct Destination: Encodable, Equatable {
178
178
}
179
179
/// Cache storage for sdk platform path.
180
180
private static var _sdkPlatformFrameworkPath : ( fwk: AbsolutePath , lib: AbsolutePath ) ? = nil
181
+
182
+ /// Returns a default destination of a given target environment
183
+ public static func defaultDestination( for triple: Triple , host: Destination ) -> Destination ? {
184
+ if triple. isWASI ( ) {
185
+ let wasiSysroot = host. binDir
186
+ . parentDirectory // usr
187
+ . appending ( components: " share " , " wasi-sysroot " )
188
+ return Destination (
189
+ target: triple,
190
+ sdk: wasiSysroot,
191
+ binDir: host. binDir,
192
+ extraCCFlags: [ ] ,
193
+ extraSwiftCFlags: [ ] ,
194
+ extraCPPFlags: [ ]
195
+ )
196
+ }
197
+ return nil
198
+ }
181
199
}
182
200
183
201
extension Destination {
You can’t perform that action at this time.
0 commit comments