Skip to content

Commit 31992e4

Browse files
committed
Do not add precompiled bridging header to a Compile job's display inputs
"Display inputs" are used to convey to the user/client the set of input files that a given compile job will build, e.g. in parseable-output. The driver is relying on the presence of the bridging PCH in `displayInputs` because the `printActions` code relies on `displayInputs`, when they are present. Unlike parseable-output, action printing is used for compiler debugging purposes only, and given that `printActions` is a best-effort emulation of the legacy driver behavior that doesn't really exist in the new driver, we can just as well get away with using `primaryInputs` and ensure `compile` job actions refer to the corresponding precompiled header, to keep the C++ tests passing (`test/Driver/actions.swift` & `test/Driver/actions-dsym.swift`).
1 parent c947d59 commit 31992e4

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,13 @@ extension Driver {
10801080
}
10811081
// All input action IDs for this action.
10821082
var inputIds = [UInt]()
1083+
1084+
var jobInputs = job.primaryInputs.isEmpty ? job.inputs : job.primaryInputs
1085+
if let pchPath = bridgingPrecompiledHeader, job.kind == .compile {
1086+
jobInputs.append(TypedVirtualPath(file: pchPath, type: .pch))
1087+
}
10831088
// Collect input job IDs.
1084-
for input in job.displayInputs.isEmpty ? job.inputs : job.displayInputs {
1089+
for input in jobInputs {
10851090
if let id = inputIdMap[input] {
10861091
inputIds.append(id)
10871092
continue

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,17 @@ extension Driver {
304304
inputs.append(TypedVirtualPath(file: moduleOutputInfo.output!.outputPath, type: .swiftModule))
305305
}
306306

307-
var displayInputs = primaryInputs
308-
309307
// Bridging header is needed for compiling these .swift sources.
310308
if let pchPath = bridgingPrecompiledHeader {
311309
let pchInput = TypedVirtualPath(file: pchPath, type: .pch)
312310
inputs.append(pchInput)
313-
displayInputs.append(pchInput)
314311
}
315312
return Job(
316313
moduleName: moduleOutputInfo.name,
317314
kind: .compile,
318315
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
319316
commandLine: commandLine,
320-
displayInputs: displayInputs,
317+
displayInputs: primaryInputs,
321318
inputs: inputs,
322319
primaryInputs: primaryInputs,
323320
outputs: outputs,

Sources/SwiftDriver/Jobs/Job.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ public struct Job: Codable, Equatable, Hashable {
6767
/// Whether or not the job supports using response files to pass command line arguments.
6868
public var supportsResponseFiles: Bool
6969

70-
/// The list of inputs to use for displaying purposes.
71-
public var displayInputs: [TypedVirtualPath]
72-
73-
/// The list of inputs for this job.
70+
/// The list of inputs for this job. These are all files that must be provided in order for this job to execute,
71+
/// and this list, along with the corresponding `outputs` is used to establish producer-consumer dependency
72+
/// relationship among jobs.
7473
public var inputs: [TypedVirtualPath]
7574

75+
/// The list of inputs to use for displaying purposes. These files are the ones the driver will communicate
76+
/// to the user/client as being objects of the selected compilation action.
77+
/// For example, a frontend job to compile a `.swift` source file may require multiple binary `inputs`,
78+
/// such as a pre-compiled bridging header and binary Swift module dependencies, but only the input `.swift`
79+
/// source file is meant to be the displayed object of compilation - a display input.
80+
public var displayInputs: [TypedVirtualPath]
81+
7682
/// The primary inputs for compile jobs
7783
public var primaryInputs: [TypedVirtualPath]
7884

0 commit comments

Comments
 (0)