Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Execution/ArgsResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public struct ArgsResolver {

// Otherwise, return the path.
return path.name
case .responseFilePath(let path):
return "@\(try resolve(.path(path)))"
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Jobs/CommandLineArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ extension Array where Element == Job.ArgTemplate {
return string.spm_shellEscaped()
case .path(let path):
return path.name.spm_shellEscaped()
case .responseFilePath(let path):
return "@\(path.name.spm_shellEscaped())"
}
}.joined(separator: " ")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ extension GenericUnixToolchain {
let inputFiles: [Job.ArgTemplate] = inputs.map { input in
// Autolink inputs are handled specially
if input.type == .autolink {
return .flag("@\(input.file.name)")
return .responseFilePath(input.file)
}
return .path(input.file)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ extension GenericUnixToolchain {
guard fileSystem.isFile(linkFile) else {
fatalError("\(linkFile.pathString) not found")
}
commandLine.appendFlag("@\(linkFile.pathString)")
commandLine.append(.responseFilePath(.absolute(linkFile)))
}

// Explicitly pass the target to the linker
Expand Down
12 changes: 11 additions & 1 deletion Sources/SwiftDriver/Jobs/Job.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public struct Job: Codable, Equatable, Hashable {

/// Represents a virtual path on disk.
case path(VirtualPath)

/// Represents a response file path prefixed by '@'.
case responseFilePath(VirtualPath)
}

/// The Swift module this job involves.
Expand Down Expand Up @@ -211,7 +214,7 @@ extension Job.Kind {

extension Job.ArgTemplate: Codable {
private enum CodingKeys: String, CodingKey {
case flag, path
case flag, path, responseFilePath
}

public func encode(to encoder: Encoder) throws {
Expand All @@ -223,6 +226,9 @@ extension Job.ArgTemplate: Codable {
case let .path(a1):
var unkeyedContainer = container.nestedUnkeyedContainer(forKey: .path)
try unkeyedContainer.encode(a1)
case let .responseFilePath(a1):
var unkeyedContainer = container.nestedUnkeyedContainer(forKey: .responseFilePath)
try unkeyedContainer.encode(a1)
}
}

Expand All @@ -240,6 +246,10 @@ extension Job.ArgTemplate: Codable {
var unkeyedValues = try values.nestedUnkeyedContainer(forKey: key)
let a1 = try unkeyedValues.decode(VirtualPath.self)
self = .path(a1)
case .responseFilePath:
var unkeyedValues = try values.nestedUnkeyedContainer(forKey: key)
let a1 = try unkeyedValues.decode(VirtualPath.self)
self = .responseFilePath(a1)
}
}
}
1 change: 1 addition & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertTrue(cmd.contains(.flag("-shared")))
XCTAssertTrue(cmd.contains(.path(.temporary(RelativePath("foo.o")))))
XCTAssertTrue(cmd.contains(.path(.temporary(RelativePath("bar.o")))))
XCTAssertTrue(cmd.contains(.responseFilePath(.temporary(RelativePath("Test.autolink")))))
XCTAssertEqual(linkJob.outputs[0].file, try VirtualPath(path: "libTest.so"))

XCTAssertFalse(cmd.contains(.flag("-dylib")))
Expand Down