Skip to content

Commit 73d004d

Browse files
committed
Only pass --rsp-quoting=windows to clang
We were unconditionally passing `--rsp-quoting` to the linker on Windows. As far as I can tell, there are three different linkers we invoke on Windows: - `clang.exe`: This is what this fix is intended to cover - `lld-link.exe`: Defaults to Windows quoting style in response files and `--rsp-quoting=windows` is a no-op. - `link.exe`: Does not accept `--rsp-quoting=windows` Move `--rsp-quoting=windows` to the point where we decide to use `clang.exe` as the linker on Windows and only pass it to `clang.exe`.
1 parent ea3fbf8 commit 73d004d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Sources/SwiftDriver/Jobs/LinkJob.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ extension Driver {
4949
mutating func linkJob(inputs: [TypedVirtualPath]) throws -> Job {
5050
var commandLine: [Job.ArgTemplate] = []
5151

52-
#if os(Windows)
53-
// We invoke clang as `clang.exe`, which expects a POSIX-style response file by default (`clang-cl.exe` expects
54-
// Windows-style response files).
55-
// The driver is outputting Windows-style response files because swift-frontend expects Windows-style response
56-
// files.
57-
// Force `clang.exe` into parsing Windows-style response files.
58-
commandLine.appendFlag("--rsp-quoting=windows")
59-
#endif
60-
6152
// Compute the final output file
6253
let outputFile: VirtualPath
6354
if let output = parsedOptions.getLastArgument(.o) {

Sources/SwiftDriver/Jobs/WindowsToolchain+LinkerSupport.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ extension WindowsToolchain {
9494
let clangTool: Tool = cxxCompatEnabled ? .clangxx : .clang
9595
var clang = try getToolPath(clangTool)
9696

97+
// We invoke clang as `clang.exe`, which expects a POSIX-style response file by default (`clang-cl.exe` expects
98+
// Windows-style response files).
99+
// The driver is outputting Windows-style response files because swift-frontend expects Windows-style response
100+
// files.
101+
// Force `clang.exe` into parsing Windows-style response files.
102+
commandLine.appendFlag("--rsp-quoting=windows")
103+
97104
let targetTriple = targetInfo.target.triple
98105
if !targetTriple.triple.isEmpty {
99106
commandLine.appendFlag("-target")

0 commit comments

Comments
 (0)