about summary refs log tree commit diff
diff options
context:
space:
mode:
authorrust-bors[bot] <122020455+rust-bors[bot]@users.noreply.github.com>2025-10-04 13:28:52 +0000
committerGitHub <noreply@github.com>2025-10-04 13:28:52 +0000
commit0a1fa518c1006fdee3f029a6c91c8cd8d696b349 (patch)
tree02b69ce6f094d21306ceb235e21d926a154630e0
parenta0f398e89df9767c93c81cd58d44fdba071258a8 (diff)
parentf1f35124b15302a1341811cff787a5867389d9a2 (diff)
downloadrust-automation/bors/try-merge.tar.gz
rust-automation/bors/try-merge.zip
Auto merge of #143669 - jieyouxu:fmt-write-bloat, r=<try> automation/bors/try-merge automation/bors/try
Make sure `fmt-write-bloat` doesn't vacuously pass on no symbols

try-job: aarch64-apple
try-job: aarch64-msvc-1
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
-rw-r--r--tests/run-make/fmt-write-bloat/rmake.rs78
1 files changed, 66 insertions, 12 deletions
diff --git a/tests/run-make/fmt-write-bloat/rmake.rs b/tests/run-make/fmt-write-bloat/rmake.rs
index b7f18b384cb..a38abe2eda5 100644
--- a/tests/run-make/fmt-write-bloat/rmake.rs
+++ b/tests/run-make/fmt-write-bloat/rmake.rs
@@ -12,24 +12,78 @@
 //! present.
 //!
 //! Some CI jobs try to run faster by disabling debug assertions (through setting
-//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of
-//! additional `usize` formatting and padding related symbols.
+//! `NO_DEBUG_ASSERTIONS=1`). If std debug assertions are disabled, then we can check for the
+//! absence of additional `usize` formatting and padding related symbols.
+
+// ignore-tidy-linelength
 
 //@ ignore-cross-compile
 
-use run_make_support::artifact_names::bin_name;
+use std::path::Path;
+
 use run_make_support::env::std_debug_assertions_enabled;
-use run_make_support::rustc;
+use run_make_support::llvm::{llvm_filecheck, llvm_pdbutil};
 use run_make_support::symbols::object_contains_any_symbol_substring;
+use run_make_support::{is_windows_msvc, rfs, rustc};
 
 fn main() {
-    rustc().input("main.rs").opt().run();
-    // panic machinery identifiers, these should not appear in the final binary
-    let mut panic_syms = vec!["panic_bounds_check", "Debug"];
-    if std_debug_assertions_enabled() {
-        // if debug assertions are allowed, we need to allow these,
-        // otherwise, add them to the list of symbols to deny.
-        panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
+    let expect_no_panic_symbols = Path::new("expect_no_panic_symbols");
+    rustc().input("main.rs").output(&expect_no_panic_symbols).opt().run();
+
+    let expect_panic_symbols = Path::new("expect_panic_symbols");
+    rustc().input("main.rs").output(&expect_panic_symbols).run();
+
+    if is_windows_msvc() {
+        // FIXME(#143737): use actual DIA wrappers instead of parsing `llvm-pdbutil` textual output.
+
+        let expect_no_filecheck_pattern = r#"
+            CHECK: main
+            CHECK-NOT: {{.*}}Display{{.*}}
+            CHECK-NOT: {{.*}}panic_bounds_check{{.*}}
+        "#;
+        let expect_no_filecheck_path = Path::new("expect_no_panic_symbols_filecheck.txt");
+        rfs::write(&expect_no_filecheck_path, expect_no_filecheck_pattern);
+
+        let expect_no_panic_symbols_pdbutil_dump = llvm_pdbutil()
+            .arg("dump")
+            .arg("-publics")
+            .input(expect_no_panic_symbols.with_extension("pdb"))
+            .run();
+        llvm_filecheck()
+            .patterns(expect_no_filecheck_path)
+            .stdin_buf(expect_no_panic_symbols_pdbutil_dump.stdout_utf8())
+            .run();
+
+        let expect_filecheck_pattern = r#"
+            CHECK: main
+            CHECK: {{.*}}core{{.*}}fmt{{.*}}write{{.*}}
+            CHECK: {{.*}}core{{.*}}panicking{{.*}}panic_fmt{{.*}}
+            // _ZN4core3fmt3num3imp54_$LT$impl$u20$core..fmt..Display$u20$for$u20$usize...
+            CHECK: {{.*}}Display{{.*}}
+            CHECK-NOT: {{.*}}panic_bounds_check{{.*}}
+        "#;
+        let expect_filecheck_path = Path::new("expect_panic_symbols_filecheck.txt");
+        rfs::write(&expect_filecheck_path, expect_filecheck_pattern);
+
+        let expect_panic_symbols_pdbutil_dump = llvm_pdbutil()
+            .arg("dump")
+            .arg("-publics")
+            .input(expect_panic_symbols.with_extension("pdb"))
+            .run();
+        llvm_filecheck()
+            .patterns(expect_filecheck_path)
+            .stdin_buf(expect_panic_symbols_pdbutil_dump.stdout_utf8())
+            .run();
+    } else {
+        // panic machinery identifiers, these should not appear in the final binary
+        let mut panic_syms = vec!["panic_bounds_check", "Debug"];
+        if std_debug_assertions_enabled() {
+            // If std debug assertions are allowed, we need to allow these, otherwise, add them to
+            // the list of symbols to deny.
+            panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
+        }
+
+        assert!(!object_contains_any_symbol_substring(&expect_no_panic_symbols, &panic_syms));
+        assert!(object_contains_any_symbol_substring(&expect_panic_symbols, &panic_syms));
     }
-    assert!(!object_contains_any_symbol_substring(bin_name("main"), &panic_syms));
 }