Skip to content

Commit

Permalink
Always emit native-static-libs note, even if it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed May 20, 2024
1 parent d84b903 commit 5cfe020
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 @@ -1536,17 +1536,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 5cfe020

Please sign in to comment.