Skip to content

Commit 74875d8

Browse files
committed
Add LTO support for WindowsToolchain
1 parent b1e5ef9 commit 74875d8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Sources/SwiftDriver/Jobs/WindowsToolchain+LinkerSupport.swift

+11
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ extension WindowsToolchain {
117117
return .responseFilePath(input.file)
118118
} else if input.type == .object {
119119
return .path(input.file)
120+
} else if lto != nil && input.type == .llvmBitcode {
121+
return .path(input.file)
120122
} else {
121123
return nil
122124
}
@@ -162,6 +164,15 @@ extension WindowsToolchain {
162164
}
163165
}
164166

167+
if let lto = lto {
168+
switch lto {
169+
case .llvmFull:
170+
commandLine.appendFlag("-flto=full")
171+
case .llvmThin:
172+
commandLine.appendFlag("-flto=thin")
173+
}
174+
}
175+
165176
// Run clang++ in verbose mode if "-v" is set
166177
try commandLine.appendLast(.v, from: &parsedOptions)
167178

Sources/SwiftDriver/Toolchains/WindowsToolchain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ extension WindowsToolchain {
137137
case .illegalCrtName(let argument):
138138
return "\(argument) is not a valid C Runtime for Windows"
139139
case .sdkNotFound:
140-
return "swift development on Windows always requires SDK of the target platform"
140+
return "swift development on Windows always requires the SDK of target platform"
141141
}
142142
}
143143
}

0 commit comments

Comments
 (0)