diff --git a/tests/run-make/remap-path-prefix-std/rmake.rs b/tests/run-make/remap-path-prefix-std/rmake.rs index f5179038a9b11..6e3bb69705c94 100644 --- a/tests/run-make/remap-path-prefix-std/rmake.rs +++ b/tests/run-make/remap-path-prefix-std/rmake.rs @@ -1,5 +1,6 @@ // This test makes sure that we do not leak paths to the checkout -// (ie. /checkout in CI) in the distributed `libstd` debuginfo. +// (ie. /checkout in CI) in the distributed standard library debuginfo. +// It checks all rlibs found in the target libdir, not just libstd. // // This test only runs on Linux and dist builder (or with `rust.remap-debuginfo = true` // set in your `bootstrap.toml`). @@ -24,30 +25,70 @@ fn main() { path }; - // Find all the `libstd-.*.rlib` files under the libdir - let libstd_rlibs = shallow_find_files(&target_libdir, |p| { + // Find all rlib files under the libdir (the full standard library set) + let all_rlibs = shallow_find_files(&target_libdir, |p| { if let Some(filename) = p.file_name() && let filename = filename.to_string_lossy() + && let Some(ext) = p.extension() + && filename.starts_with("lib") + && ext == "rlib" + && filename.contains('-') { - filename.starts_with("libstd-") && filename.ends_with(".rlib") + true } else { false } }); - // Assert that there is only one rlib for the `libstd` - let [libstd_rlib] = &libstd_rlibs[..] else { - unreachable!("multiple libstd rlib: {libstd_rlibs:?} in {target_libdir:?}"); - }; + // There must be at least one rlib (libstd itself, plus many others) + assert!(!all_rlibs.is_empty(), "no rlibs found in target libdir {target_libdir:?}"); + + for rlib in &all_rlibs { + // Use a stable symlink name based on the crate part (before the '-' suffix). + // e.g. "libstd-92abaa9b58c011c1.rlib" → "libstd.rlib" + let filename = rlib.file_name().unwrap().to_string_lossy(); + let link_name = match filename.split_once('-') { + Some((prefix, _)) => format!("{prefix}.rlib"), + None => filename.to_string(), + }; - // Symlink the libstd rlib here to avoid absolute paths from llvm-dwarfdump own output - // and not from the debuginfo it-self - rfs::symlink_file(libstd_rlib, "libstd.rlib"); + // Symlink the original rlib to avoid absolute paths from dwarfdump itself + rfs::symlink_file(rlib, &link_name); + + // Check that no distributed rlib leaks the checkout/source root path. + let completed = llvm_dwarfdump().input(&link_name).run_unchecked(); + if !completed.status().success() { + eprintln!("dwarfdump failed on {link_name}: exit status {:?}", completed.status()); + panic!("llvm-dwarfdump failed for {link_name}"); + } + + let stdout = completed.stdout_utf8(); + let source_root = source_root(); + let root = source_root.to_string_lossy(); + + if let Some((i, _)) = + stdout.lines().enumerate().find(|(_, line)| line.contains(root.as_ref())) + { + let lines: Vec<_> = stdout.lines().collect(); - // Check that there is only `/rustc/` paths and no `/checkout`, `/home`, or whatever - llvm_dwarfdump() - .input("libstd.rlib") - .run() - .assert_stdout_contains("/rustc/") - .assert_stdout_not_contains(source_root().to_string_lossy()); + let start = i.saturating_sub(2); + let end = (i + 3).min(lines.len()); + + eprintln!("leaked source-root path found in {link_name}:"); + + for line in &lines[start..end] { + eprintln!("{line}"); + } + + panic!("found leaked source-root path in {link_name}"); + } + + // Check that remapped paths are present if the rlib has debug info. + if stdout.contains("DW_TAG_compile_unit") { + assert!( + stdout.contains("/rustc/") || stdout.contains("/rust/deps"), + "Expected remapped paths in dwarfdump output for {link_name}", + ); + } + } } diff --git a/tests/rustdoc-ui/ice-bug-report-url.rs b/tests/rustdoc-ui/ice-bug-report-url.rs index 2e384fa1be623..5aa82c438fa36 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.rs +++ b/tests/rustdoc-ui/ice-bug-report-url.rs @@ -4,7 +4,7 @@ //@ normalize-stderr: "note: compiler flags.*\n\n" -> "" //@ normalize-stderr: "note: rustc.*running on.*" -> "note: rustc {version} running on {platform}" -//@ normalize-stderr: "thread.*panicked at compiler.*" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ normalize-stderr: " +\d{1,}: .*\n" -> "" //@ normalize-stderr: " + at .*\n" -> "" //@ normalize-stderr: ".*note: Some details are omitted.*\n" -> "" diff --git a/tests/rustdoc-ui/ice-bug-report-url.stderr b/tests/rustdoc-ui/ice-bug-report-url.stderr index bc46b226a703e..01dac0433e630 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.stderr +++ b/tests/rustdoc-ui/ice-bug-report-url.stderr @@ -5,8 +5,6 @@ LL | fn wrong() | ^ expected one of `->`, `where`, or `{` - -aborting due to `-Z treat-err-as-bug=1` stack backtrace: error: the compiler unexpectedly panicked. This is a bug diff --git a/tests/rustdoc-ui/track-diagnostics.rs b/tests/rustdoc-ui/track-diagnostics.rs index f8e710659a5c8..e1b2aa01298a2 100644 --- a/tests/rustdoc-ui/track-diagnostics.rs +++ b/tests/rustdoc-ui/track-diagnostics.rs @@ -3,6 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" +//@ normalize-stderr: "/rustc(?:-dev)?/[a-z0-9.]+/" -> "" struct A; struct B;