Skip to content

Commit

Permalink
Rollup merge of rust-lang#121216 - madsmtm:fix-108825, r=wesleywiser
Browse files Browse the repository at this point in the history
Always emit `native-static-libs` note, even if it is empty

Fixes rust-lang#108825.
  • Loading branch information
matthiaskrgr committed Jun 13, 2024
2 parents 9fdbfe1 + 5cfe020 commit 32b7592
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
14 changes: 5 additions & 9 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,17 +1561,13 @@ fn print_native_static_libs(
match out {
OutFileName::Real(path) => {
out.overwrite(&lib_args.join(" "), sess);
if !lib_args.is_empty() {
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
}
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
}
OutFileName::Stdout => {
if !lib_args.is_empty() {
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
// Prefix for greppability
// Note: This must not be translated as tools are allowed to depend on this exact string.
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
}
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
// Prefix for greppability
// Note: This must not be translated as tools are allowed to depend on this exact string.
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/codegen/empty-static-libs-issue-108825.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test that linking a no_std application still outputs the
// `native-static-libs: ` note, even though it's empty.
//@ compile-flags: -Cpanic=abort --print=native-static-libs
//@ build-pass
//@ ignore-wasm
//@ ignore-cross-compile This doesn't produce any output on i686-unknown-linux-gnu for some reason?

#![crate_type = "staticlib"]
#![no_std]

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
4 changes: 4 additions & 0 deletions tests/ui/codegen/empty-static-libs-issue-108825.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.

note: native-static-libs:

0 comments on commit 32b7592

Please sign in to comment.