Skip to content

Commit

Permalink
Only run the symbols-all-mangled test on Linux
Browse files Browse the repository at this point in the history
Other platforms may add other unmangled symbols through crt1.o and such.
  • Loading branch information
bjorn3 committed Mar 3, 2025
1 parent 275f3fa commit e377765
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/run-make/symbols-all-mangled/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Check that all symbols in cdylibs, staticlibs and bins are mangled
//@ only-linux (non-linux has other symbols, unreasonable to exhaustively check)

use run_make_support::object::read::{Object, ObjectSymbol};
use run_make_support::{bin_name, dynamic_lib_name, object, rfs, rustc, static_lib_name};
Expand All @@ -21,7 +22,7 @@ fn symbols_check_archive(path: &str) {
let file = object::read::archive::ArchiveFile::parse(&*binary_data).unwrap();
for symbol in file.symbols().unwrap().unwrap() {
let symbol = symbol.unwrap();
let name = strip_underscore_if_apple(std::str::from_utf8(symbol.name()).unwrap());
let name = std::str::from_utf8(symbol.name()).unwrap();
if name.starts_with("_ZN") || name.starts_with("_R") {
continue; // Correctly mangled
}
Expand Down Expand Up @@ -54,7 +55,7 @@ fn symbols_check(path: &str) {
if symbol.is_weak() {
continue; // Likely an intrinsic from compiler-builtins
}
let name = strip_underscore_if_apple(symbol.name().unwrap());
let name = symbol.name().unwrap();
if name.starts_with("_ZN") || name.starts_with("_R") {
continue; // Correctly mangled
}
Expand All @@ -78,7 +79,3 @@ fn symbols_check(path: &str) {
panic!("Unmangled symbol found: {name}");
}
}

fn strip_underscore_if_apple(symbol: &str) -> &str {
if cfg!(target_vendor = "apple") { symbol.strip_prefix("_").unwrap() } else { symbol }
}

0 comments on commit e377765

Please sign in to comment.