Skip to content

Commit 91c7d8e

Browse files
committed
SwiftDriver: enable response files on LinkJobs
The non-Darwin targets use clang as the linker driver. As a result, the non-Darwin targets implicitly support response files (clang will expand it if the linker does not support response files or file lists). Unfortunately, the Darwin target manually invokes ld, which requires re-implementing the handling there. To complicate things further, older ld64 does not support response files, but does support linker file lists, while newer ld64 supports both. Ideally, Darwin would also use clang as the linker driver to homogenise the paths. This is required for Windows support as the command line limit is much lower on Windows than on Linux - nearing 4k which is possible to exceed when building a larger project (e.g. swift-driver).
1 parent 90e1502 commit 91c7d8e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/SwiftDriver/Jobs/LinkJob.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ extension Driver {
6464
targetInfo: frontendTargetInfo
6565
)
6666

67-
// TODO: some, but not all, linkers support response files.
6867
return Job(
6968
moduleName: moduleOutputInfo.name,
7069
kind: .link,
@@ -73,7 +72,10 @@ extension Driver {
7372
displayInputs: inputs,
7473
inputs: inputs,
7574
primaryInputs: [],
76-
outputs: [.init(file: outputFile.intern(), type: .image)]
75+
outputs: [.init(file: outputFile.intern(), type: .image)],
76+
// FIXME: newer ld64 supports response files as well, though really,
77+
// Darwin should use clang as the linker driver like the other targets
78+
supportsResponseFiles: !frontendTargetInfo.target.triple.isDarwin
7779
)
7880
}
7981
}

0 commit comments

Comments
 (0)