File tree 3 files changed +14
-11
lines changed
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 {
196
196
}
197
197
198
198
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
- }
202
199
guard useResponseFiles != . disabled else {
203
200
return false
204
201
}
@@ -214,11 +211,8 @@ public final class ArgsResolver {
214
211
215
212
// FIXME: Need a way to support this for distributed build systems...
216
213
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.
220
214
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 " ) )
222
216
}
223
217
resolvedArguments = [ resolvedArguments [ 0 ] , resolvedArguments [ 1 ] , " @ \( absPath. pathString) " ]
224
218
}
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ extension Driver {
49
49
mutating func linkJob( inputs: [ TypedVirtualPath ] ) throws -> Job {
50
50
var commandLine : [ Job . ArgTemplate ] = [ ]
51
51
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
+
52
61
// Compute the final output file
53
62
let outputFile : VirtualPath
54
63
if let output = parsedOptions. getLastArgument ( . o) {
Original file line number Diff line number Diff line change @@ -1696,9 +1696,9 @@ final class SwiftDriverTests: XCTestCase {
1696
1696
XCTAssertEqual ( resolvedArgs [ 2 ] . first, " @ " )
1697
1697
let responseFilePath = try AbsolutePath ( validating: String ( resolvedArgs [ 2 ] . dropFirst ( ) ) )
1698
1698
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 " ) )
1702
1702
}
1703
1703
1704
1704
// Needs response file + disable override
@@ -1725,7 +1725,7 @@ final class SwiftDriverTests: XCTestCase {
1725
1725
XCTAssertEqual ( resolvedArgs [ 2 ] . first, " @ " )
1726
1726
let responseFilePath = try AbsolutePath ( validating: String ( resolvedArgs [ 2 ] . dropFirst ( ) ) )
1727
1727
let contents = try localFileSystem. readFileContents ( responseFilePath) . description
1728
- XCTAssertTrue ( contents. hasPrefix ( " \" -interpret \" \n \" /foo.swift \" " ) )
1728
+ XCTAssertTrue ( contents. hasPrefix ( " -interpret \n /foo.swift " ) )
1729
1729
}
1730
1730
1731
1731
// No response file
You can’t perform that action at this time.
0 commit comments