File tree Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Expand file tree Collapse file tree 3 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -196,9 +196,6 @@ public final class ArgsResolver {
196196 }
197197
198198 private func createResponseFileIfNeeded( for job: Job , resolvedArguments: inout [ String ] , useResponseFiles: ResponseFileHandling ) throws -> Bool {
199- func quote( _ string: String ) -> String {
200- return " \" \( String ( string. flatMap { [ " \\ " , " \" " ] . contains ( $0) ? " \\ \( $0) " : " \( $0) " } ) ) \" "
201- }
202199 guard useResponseFiles != . disabled else {
203200 return false
204201 }
@@ -214,11 +211,8 @@ public final class ArgsResolver {
214211
215212 // FIXME: Need a way to support this for distributed build systems...
216213 if let absPath = responseFilePath. absolutePath {
217- // Adopt the same technique as clang -
218- // Wrap all arguments in double quotes to ensure that both Unix and
219- // Windows tools understand the response file.
220214 try fileSystem. writeFileContents ( absPath) {
221- $0. send ( resolvedArguments [ 2 ... ] . map { quote ( $0 ) } . joined ( separator: " \n " ) )
215+ $0. send ( resolvedArguments [ 2 ... ] . map { $0 . spm_shellEscaped ( ) } . joined ( separator: " \n " ) )
222216 }
223217 resolvedArguments = [ resolvedArguments [ 0 ] , resolvedArguments [ 1 ] , " @ \( absPath. pathString) " ]
224218 }
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ 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+
5261 // Compute the final output file
5362 let outputFile : VirtualPath
5463 if let output = parsedOptions. getLastArgument ( . o) {
Original file line number Diff line number Diff line change @@ -1696,9 +1696,9 @@ final class SwiftDriverTests: XCTestCase {
16961696 XCTAssertEqual ( resolvedArgs [ 2 ] . first, " @ " )
16971697 let responseFilePath = try AbsolutePath ( validating: String ( resolvedArgs [ 2 ] . dropFirst ( ) ) )
16981698 let contents = try localFileSystem. readFileContents ( responseFilePath) . description
1699- XCTAssertTrue ( contents. hasPrefix ( " \" -interpret \" \n \" /foo.swift \" " ) )
1700- XCTAssertTrue ( contents. contains ( " \" -D \" \n \" TEST_20000 \" " ) )
1701- XCTAssertTrue ( contents. contains ( " \" -D \" \n \" TEST_1 \" " ) )
1699+ XCTAssertTrue ( contents. hasPrefix ( " -interpret \n /foo.swift " ) )
1700+ XCTAssertTrue ( contents. contains ( " -D \n TEST_20000 " ) )
1701+ XCTAssertTrue ( contents. contains ( " -D \n TEST_1 " ) )
17021702 }
17031703
17041704 // Needs response file + disable override
@@ -1725,7 +1725,7 @@ final class SwiftDriverTests: XCTestCase {
17251725 XCTAssertEqual ( resolvedArgs [ 2 ] . first, " @ " )
17261726 let responseFilePath = try AbsolutePath ( validating: String ( resolvedArgs [ 2 ] . dropFirst ( ) ) )
17271727 let contents = try localFileSystem. readFileContents ( responseFilePath) . description
1728- XCTAssertTrue ( contents. hasPrefix ( " \" -interpret \" \n \" /foo.swift \" " ) )
1728+ XCTAssertTrue ( contents. hasPrefix ( " -interpret \n /foo.swift " ) )
17291729 }
17301730
17311731 // No response file
You can’t perform that action at this time.
0 commit comments