Skip to content

Commit 1eca355

Browse files
committed
Use UUID to unique response file names, instead of content hash
We've been having issues with content hash causing collisions as well as issues with underlying Foundation atomic APIs. For now, attempt to simply make the files unique with a uuid.
1 parent 3093b07 commit 1eca355

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/SwiftDriver/Execution/ArgsResolver.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import class Foundation.NSLock
14+
import struct Foundation.UUID
1415

1516
import func TSCBasic.withTemporaryDirectory
1617
import protocol TSCBasic.FileSystem
@@ -189,14 +190,13 @@ public final class ArgsResolver {
189190
(job.supportsResponseFiles && !commandLineFitsWithinSystemLimits(path: resolvedArguments[0], args: resolvedArguments)) {
190191
assert(!forceResponseFiles || job.supportsResponseFiles,
191192
"Platform does not support response files for job: \(job)")
192-
// Match the integrated driver's behavior, which uses response file names of the form "arguments-[0-9a-zA-Z].resp".
193-
let hash = SHA256().hash(resolvedArguments.joined(separator: " ")).hexadecimalRepresentation
194-
let responseFilePath = temporaryDirectory.appending(component: "arguments-\(hash).resp")
193+
let uuid = UUID().uuidString
194+
let responseFilePath = temporaryDirectory.appending(component: "arguments-\(uuid).resp")
195195

196196
// FIXME: Need a way to support this for distributed build systems...
197197
if let absPath = responseFilePath.absolutePath {
198198
let argumentBytes = ByteString(resolvedArguments[2...].map { $0.spm_shellEscaped() }.joined(separator: "\n").utf8)
199-
try fileSystem.writeFileContents(absPath, bytes: argumentBytes, atomically: true)
199+
try fileSystem.writeFileContents(absPath, bytes: argumentBytes)
200200
resolvedArguments = [resolvedArguments[0], resolvedArguments[1], "@\(absPath.pathString)"]
201201
}
202202

0 commit comments

Comments
 (0)