@@ -27,27 +27,15 @@ import SwiftOptions
2727
2828 // An externally provided path from where we should find tools like ld
2929 public let toolDirectory : AbsolutePath ?
30-
31- public let dummyForTestingObjectFormat = Triple . ObjectFormat. coff
32-
33- public func archName( for triple: Triple ) -> String {
34- switch triple. arch {
35- case . aarch64: return " aarch64 "
36- case . arm: return " armv7 "
37- case . x86: return " i386 "
38- case nil , . x86_64: return " x86_64 "
39- default : fatalError ( " unknown arch \( triple. archName) for Windows " )
40- }
41- }
4230
43- public init ( env: [ String : String ] , executor: DriverExecutor , fileSystem: FileSystem = localFileSystem, toolDirectory: AbsolutePath ? = nil ) {
44- self . env = env
45- self . executor = executor
46- self . fileSystem = fileSystem
47- self . toolDirectory = toolDirectory
48- }
31+ public let dummyForTestingObjectFormat = Triple . ObjectFormat. coff
4932
50-
33+ public init ( env: [ String : String ] , executor: DriverExecutor , fileSystem: FileSystem = localFileSystem, toolDirectory: AbsolutePath ? = nil ) {
34+ self . env = env
35+ self . executor = executor
36+ self . fileSystem = fileSystem
37+ self . toolDirectory = toolDirectory
38+ }
5139
5240 /// Retrieve the absolute path for a given tool.
5341 public func getToolPath( _ tool: Tool ) throws -> AbsolutePath {
@@ -68,7 +56,6 @@ import SwiftOptions
6856 case . staticLinker:
6957 return try lookup ( executable: " lib " )
7058 case . dynamicLinker:
71- // FIXME: This needs to look in the tools_directory first.
7259 return try lookup ( executable: " link " )
7360 case . clang:
7461 return try lookup ( executable: " clang " )
@@ -88,19 +75,19 @@ import SwiftOptions
8875 public func overrideToolPath( _ tool: Tool , path: AbsolutePath ) {
8976 toolPaths [ tool] = path
9077 }
91-
92- /// Path to the StdLib inside the SDK.
93- public func sdkStdlib( sdk: AbsolutePath , triple: Triple ) -> AbsolutePath {
94- sdk. appending ( RelativePath ( " usr/lib/swift/windows " ) ) . appending ( component: archName ( for: triple) )
95- }
96-
97- public func makeLinkerOutputFilename( moduleName: String , type: LinkOutputType ) -> String {
98- switch type {
99- case . executable: return " \( moduleName) .exe "
100- case . dynamicLibrary: return " \( moduleName) .dll "
101- case . staticLibrary: return " lib \( moduleName) .lib "
102- }
78+
79+ /// Path to the StdLib inside the SDK.
80+ public func sdkStdlib( sdk: AbsolutePath , triple: Triple ) -> AbsolutePath {
81+ sdk. appending ( RelativePath ( " usr/lib/swift/windows " ) ) . appending ( component: triple. archName)
82+ }
83+
84+ public func makeLinkerOutputFilename( moduleName: String , type: LinkOutputType ) -> String {
85+ switch type {
86+ case . executable: return " \( moduleName) .exe "
87+ case . dynamicLibrary: return " \( moduleName) .dll "
88+ case . staticLibrary: return " lib \( moduleName) .lib "
10389 }
90+ }
10491
10592 public func defaultSDKPath( _ target: Triple ? ) throws -> AbsolutePath ? {
10693 return nil
@@ -113,7 +100,7 @@ import SwiftOptions
113100 targetTriple: Triple ,
114101 isShared: Bool
115102 ) throws -> String {
116- return " clang_rt. \( sanitizer. libraryName) - \( archName ( for : targetTriple) ) .lib "
103+ return " clang_rt. \( sanitizer. libraryName) - \( targetTriple. archName ) .lib "
117104 }
118105}
119106
@@ -141,13 +128,16 @@ extension WindowsToolchain {
141128 public enum ToolchainValidationError : Error , DiagnosticData {
142129 case argumentNotSupported( String )
143130 case illegalCrtName( String )
131+ case sdkNotFound
144132
145133 public var description : String {
146134 switch self {
147135 case . argumentNotSupported( let argument) :
148136 return " \( argument) is not supported for Windows "
149137 case . illegalCrtName( let argument) :
150138 return " \( argument) is not a valid C Runtime for Windows "
139+ case . sdkNotFound:
140+ return " swift development on Windows always requires SDK of the target platform "
151141 }
152142 }
153143 }
0 commit comments