diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-03-27 15:57:26 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-27 15:57:26 +1100 |
| commit | 8fa981665cd9b8927e9eaf04bb1fe008ceb62b7d (patch) | |
| tree | 7993a67023ff17ef05f1d26c6a597963228e2170 | |
| parent | 3db09991002088c35061606e96e0f625e31e7579 (diff) | |
| parent | d1cd621b55a7def094f5cfecb99d2909b2d0e701 (diff) | |
| download | rust-8fa981665cd9b8927e9eaf04bb1fe008ceb62b7d.tar.gz rust-8fa981665cd9b8927e9eaf04bb1fe008ceb62b7d.zip | |
Rollup merge of #138987 - madsmtm:fix-108825, r=jieyouxu
Always emit `native-static-libs` note, even if it is empty Fixes https://github.com/rust-lang/rust/issues/108825. Retry of https://github.com/rust-lang/rust/pull/121216, finally got around to fixing the test, the errors in that PR were because `libcore` uses the `#[link]` attribute on MSVC. try-job: x86_64-msvc r? wesleywiser
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 14 | ||||
| -rw-r--r-- | tests/ui/codegen/empty-static-libs-issue-108825.rs | 16 |
2 files changed, 21 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index a564e0e391f..2e614a1f06f 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1560,17 +1560,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 00000000000..46bd6d6b2da --- /dev/null +++ b/tests/ui/codegen/empty-static-libs-issue-108825.rs @@ -0,0 +1,16 @@ +//! Test that linking a no_std application still outputs the +//! `native-static-libs: ` note, even though it is empty. + +//@ compile-flags: -Cpanic=abort --print=native-static-libs +//@ build-pass +//@ error-pattern: note: native-static-libs: +//@ dont-check-compiler-stderr (libcore links `/defaultlib:msvcrt` or `/defaultlib:libcmt` on MSVC) +//@ ignore-pass (the note is emitted later in the compilation pipeline, needs build) + +#![crate_type = "staticlib"] +#![no_std] + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} |
