Skip to content

Commit

Permalink
Auto merge of rust-lang#128807 - ChrisDenton:bloat, r=<try>
Browse files Browse the repository at this point in the history
run-make: run fmt-write-bloat on Windows

The trouble here is that libc doesn't exist on Windows. Well it kinda does but it isn't called that so we substitute a name that works. Ideally finding necessary libs for the platform would be done at a higher level but until then this should work.

try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
  • Loading branch information
bors committed Aug 8, 2024
2 parents d3a3939 + a33003b commit 7dd8f8b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/tools/run-make-support/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool
.name_bytes()
.unwrap()
.windows(substring.len())
.any(|x| x == substring.as_bytes())
.any(|x| x == substring.as_bytes() && !x.starts_with(b"__imp_"))
{
eprintln!("{:?} contains {}", sym, substring);
return true;
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/fmt-write-bloat/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use core::fmt;
use core::fmt::Write;

#[link(name = "c")]
#[cfg_attr(not(windows), link(name = "c"))]
extern "C" {}

struct Dummy;
Expand Down
7 changes: 2 additions & 5 deletions tests/run-make/fmt-write-bloat/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of
//! additional `usize` formatting and padding related symbols.

// Reason: This test is `ignore-windows` because the `no_std` test (using `#[link(name = "c")])`
// doesn't link on windows.
//@ ignore-windows
//@ ignore-cross-compile

use run_make_support::env::no_debug_assertions;
use run_make_support::rustc;
use run_make_support::symbols::any_symbol_contains;
use run_make_support::{bin_name, rustc};

fn main() {
rustc().input("main.rs").opt().run();
Expand All @@ -33,5 +30,5 @@ fn main() {
// otherwise, add them to the list of symbols to deny.
panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
}
assert!(!any_symbol_contains("main", &panic_syms));
assert!(!any_symbol_contains(&bin_name("main"), &panic_syms));
}

0 comments on commit 7dd8f8b

Please sign in to comment.