Auto merge of #119286 - jyn514:linker-output, r=bjorn3

show linker output even if the linker succeeds

Show stderr and stderr by default, controlled by a new `linker_messages` lint.

fixes https://github.com/rust-lang/rust/issues/83436. fixes https://github.com/rust-lang/rust/issues/38206. cc 408986134

<!-- try-job: dist-x86_64-msvc -->
try-job: aarch64-apple

r? `@bjorn3`
This commit is contained in:
bors 2025-01-25 17:16:33 +00:00
commit f7cc13af82
26 changed files with 350 additions and 73 deletions

View file

@ -895,13 +895,16 @@ fn default_emitter(
}
t => t,
};
let source_map = if sopts.unstable_opts.link_only { None } else { Some(source_map) };
match sopts.error_format {
config::ErrorOutputType::HumanReadable(kind, color_config) => {
let short = kind.short();
if let HumanReadableErrorType::AnnotateSnippet = kind {
let emitter = AnnotateSnippetEmitter::new(
Some(source_map),
source_map,
bundle,
fallback_bundle,
short,
@ -911,7 +914,7 @@ fn default_emitter(
} else {
let emitter = HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
.fluent_bundle(bundle)
.sm(Some(source_map))
.sm(source_map)
.short_message(short)
.teach(sopts.unstable_opts.teach)
.diagnostic_width(sopts.diagnostic_width)
@ -1442,7 +1445,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
config::ErrorOutputType::Json { pretty, json_rendered, color_config } => {
Box::new(JsonEmitter::new(
Box::new(io::BufWriter::new(io::stderr())),
Lrc::new(SourceMap::new(FilePathMapping::empty())),
Some(Lrc::new(SourceMap::new(FilePathMapping::empty()))),
fallback_bundle,
pretty,
json_rendered,