Skip to content

Commit d9ffaaf

Browse files
authored
Merge pull request #1442 from ahoppen/reduce-frontend-fixes
Fix a couple issue in the `debug reduce-swift-frontend` subcommand
2 parents 2d874a7 + 1af6f04 commit d9ffaaf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Sources/Diagnose/MergeSwiftFiles.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ extension RequestInfo {
2727

2828
progressUpdate(0, "Merging all .swift files into a single file")
2929

30+
let compilerArgs = compilerArgs.filter { $0 != "-primary-file" && !$0.hasSuffix(".swift") } + ["$FILE"]
3031
let mergedRequestInfo = RequestInfo(
3132
requestTemplate: requestTemplate,
3233
offset: offset,
33-
compilerArgs: compilerArgs.filter { !$0.hasSuffix(".swift") } + ["$FILE"],
34+
compilerArgs: compilerArgs,
3435
fileContents: mergedFile
3536
)
3637

Sources/Diagnose/ReduceFrontendCommand.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,18 @@ public struct ReduceFrontendCommand: AsyncParsableCommand {
9696
reproducerPredicate: nsPredicate
9797
)
9898

99+
defer {
100+
progressBar.complete(success: true)
101+
}
99102
let reducedRequestInfo = try await reduceFrontendIssue(
100103
frontendArgs: frontendArgs,
101104
using: executor
102105
) { progress, message in
103106
progressBar.update(step: Int(progress * 100), total: 100, text: message)
104107
}
105108

106-
progressBar.complete(success: true)
107-
108109
print("Reduced compiler arguments:")
109-
print(reducedRequestInfo.compilerArgs)
110+
print(reducedRequestInfo.compilerArgs.joined(separator: " "))
110111

111112
print("")
112113
print("Reduced file contents:")

Sources/Diagnose/RequestInfo.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ public struct RequestInfo: Sendable {
121121

122122
// Inline the file list so we can reduce the compiler arguments by removing individual source files.
123123
// A couple `output-filelist`-related compiler arguments don't work with the file list inlined. Remove them as they
124-
// are unlikely to be responsible for the swift-frontend cache
124+
// are unlikely to be responsible for the swift-frontend cache.
125+
// `-index-system-modules` is invalid when no output file lists are specified.
125126
while let frontendArg = iterator.next() {
126127
switch frontendArg {
127-
case "-supplementary-output-file-map", "-output-filelist", "-index-unit-output-path-filelist":
128+
case "-supplementary-output-file-map", "-output-filelist", "-index-unit-output-path-filelist",
129+
"-index-system-modules":
128130
_ = iterator.next()
129131
case "-filelist":
130132
guard let fileList = iterator.next() else {

0 commit comments

Comments
 (0)