Description
Diagnostics emitted by the driver itself don't obey -parseable-output
. This makes it a bit difficult for clients to handle the output and leads to things like swiftlang/swift-package-manager#5968.
Consider this command line:
❯ swiftc -parseable-output -whole-module-optimization -incremental -c foo.swift
(assuming there is a file foo.swift
). It results in:
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
1201
{
"command_arguments" : [
"-frontend",
"-c",
"foo.swift",
"-target",
"arm64-apple-macosx12.0",
"-Xllvm",
"-aarch64-use-tbi",
"-enable-objc-interop",
"-stack-check",
. . .
which is a mixture of JSON output and plain-text output. Making matters worse, both the JSON output and the diagnostics are emitted to stderr
. I would have expected that output would go to stdout when -parseable-output
is passed, while the human-readable diagnostics go to stderr
.
Alternatively, when -parseable-output
is in effect, the diagnostics from the driver could be wrapped in JSON packets reflecting the type of diagnostic so that clients don't have to handle a mixture.