Skip to content

Commit b3dbdc5

Browse files
[swift][EmitConst] Use driver flag when available
Pass `-const-gather-protocols-list` driver flag when available. rdar://169280604
1 parent b6df1df commit b3dbdc5

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,13 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
15711571
}
15721572
cbc.producer.writeFileSpec.constructFileTasks(CommandBuildContext(producer: cbc.producer, scope: cbc.scope, inputs: [], output: protocolListPath),
15731573
delegate, contents: protocolListContents, permissions: nil, preparesForIndexing: true, additionalTaskOrderingOptions: [.immediate, .ignorePhaseOrdering])
1574-
args += ["-Xfrontend", "-const-gather-protocols-file",
1575-
"-Xfrontend", protocolListPath.str]
1574+
if LibSwiftDriver.supportsDriverFlag(spelled: "-const-gather-protocols-list") {
1575+
// Use the driver option if supported.
1576+
args += ["-const-gather-protocols-list", protocolListPath.str]
1577+
} else {
1578+
args += ["-Xfrontend", "-const-gather-protocols-file",
1579+
"-Xfrontend", protocolListPath.str]
1580+
}
15761581
extraInputPaths.append(protocolListPath)
15771582
}
15781583

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,10 +2091,11 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
20912091
results.checkNoDiagnostics()
20922092
if swiftFeatures.has(.emitContValuesSidecar) {
20932093
task.checkCommandLineContains(["-emit-const-values"])
2094-
task.checkCommandLineContains(["-const-gather-protocols-file"])
2094+
task.checkCommandLineMatches([.or("-const-gather-protocols-file", "-const-gather-protocols-list")])
20952095
} else {
20962096
task.checkCommandLineDoesNotContain("-emit-const-values")
20972097
task.checkCommandLineDoesNotContain("-const-gather-protocols-file")
2098+
task.checkCommandLineDoesNotContain("-const-gather-protocols-list")
20982099
}
20992100
}
21002101

0 commit comments

Comments
 (0)