@@ -27,27 +27,15 @@ import SwiftOptions
27
27
28
28
// An externally provided path from where we should find tools like ld
29
29
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
- }
42
30
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
49
32
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
+ }
51
39
52
40
/// Retrieve the absolute path for a given tool.
53
41
public func getToolPath( _ tool: Tool ) throws -> AbsolutePath {
@@ -68,7 +56,6 @@ import SwiftOptions
68
56
case . staticLinker:
69
57
return try lookup ( executable: " lib " )
70
58
case . dynamicLinker:
71
- // FIXME: This needs to look in the tools_directory first.
72
59
return try lookup ( executable: " link " )
73
60
case . clang:
74
61
return try lookup ( executable: " clang " )
@@ -88,19 +75,19 @@ import SwiftOptions
88
75
public func overrideToolPath( _ tool: Tool , path: AbsolutePath ) {
89
76
toolPaths [ tool] = path
90
77
}
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 "
103
89
}
90
+ }
104
91
105
92
public func defaultSDKPath( _ target: Triple ? ) throws -> AbsolutePath ? {
106
93
return nil
@@ -113,7 +100,7 @@ import SwiftOptions
113
100
targetTriple: Triple ,
114
101
isShared: Bool
115
102
) throws -> String {
116
- return " clang_rt. \( sanitizer. libraryName) - \( archName ( for : targetTriple) ) .lib "
103
+ return " clang_rt. \( sanitizer. libraryName) - \( targetTriple. archName ) .lib "
117
104
}
118
105
}
119
106
@@ -141,13 +128,16 @@ extension WindowsToolchain {
141
128
public enum ToolchainValidationError : Error , DiagnosticData {
142
129
case argumentNotSupported( String )
143
130
case illegalCrtName( String )
131
+ case sdkNotFound
144
132
145
133
public var description : String {
146
134
switch self {
147
135
case . argumentNotSupported( let argument) :
148
136
return " \( argument) is not supported for Windows "
149
137
case . illegalCrtName( let argument) :
150
138
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 "
151
141
}
152
142
}
153
143
}
0 commit comments