Skip to content

Commit

Permalink
Execution: special case the first two arguments in RSP mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
compnerd committed Feb 4, 2024
1 parent 5fae1fd commit 73e6d2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftDriver/Execution/ArgsResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 73e6d2a

Please sign in to comment.