From 73e6d2af33a4958c2276fcc1a0cafded5aa106fc Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 4 Feb 2024 11:06:35 -0800 Subject: [PATCH] Execution: special case the first two arguments in RSP mode The second argument is often treated specially as a mode specifier for tools. This is particularly important for Windows where `-lib` or `/lib` passed to `link` or `ld.lld-link` will change the linker to the librarian. This argument may not be sunk into the response file as it is not treated as the mode specifier then. Special case the first two arguments to ensure that the mode switch parameter is always passed for any tools. --- Sources/SwiftDriver/Execution/ArgsResolver.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftDriver/Execution/ArgsResolver.swift b/Sources/SwiftDriver/Execution/ArgsResolver.swift index 6c8e73fbb..afef17def 100644 --- a/Sources/SwiftDriver/Execution/ArgsResolver.swift +++ b/Sources/SwiftDriver/Execution/ArgsResolver.swift @@ -216,9 +216,9 @@ public final class ArgsResolver { // Wrap all arguments in double quotes to ensure that both Unix and // Windows tools understand the response file. try fileSystem.writeFileContents(absPath) { - $0.send(resolvedArguments[1...].map { quote($0) }.joined(separator: "\n")) + $0.send(resolvedArguments[2...].map { quote($0) }.joined(separator: "\n")) } - resolvedArguments = [resolvedArguments[0], "@\(absPath.pathString)"] + resolvedArguments = [resolvedArguments[0], resolvedArguments[1], "@\(absPath.pathString)"] } return true