From 5cfe0209949f54fed1850a5cda7c20bcf1cd106d Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 17 Feb 2024 04:31:46 +0100 Subject: [PATCH] Always emit native-static-libs note, even if it is empty --- compiler/rustc_codegen_ssa/src/back/link.rs | 14 +++++--------- tests/ui/codegen/empty-static-libs-issue-108825.rs | 14 ++++++++++++++ .../codegen/empty-static-libs-issue-108825.stderr | 4 ++++ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 tests/ui/codegen/empty-static-libs-issue-108825.rs create mode 100644 tests/ui/codegen/empty-static-libs-issue-108825.stderr diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 6939674ce9dd7..d4d88c379c70b 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -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(" "))); } } } diff --git a/tests/ui/codegen/empty-static-libs-issue-108825.rs b/tests/ui/codegen/empty-static-libs-issue-108825.rs new file mode 100644 index 0000000000000..e25672a245f53 --- /dev/null +++ b/tests/ui/codegen/empty-static-libs-issue-108825.rs @@ -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 {} +} diff --git a/tests/ui/codegen/empty-static-libs-issue-108825.stderr b/tests/ui/codegen/empty-static-libs-issue-108825.stderr new file mode 100644 index 0000000000000..4f07d441fb6aa --- /dev/null +++ b/tests/ui/codegen/empty-static-libs-issue-108825.stderr @@ -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: +