Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f66adb0

Browse files
committedAug 6, 2024
port tests/run-make/extern-fn-reachable to rmake
uses helper functions added in rust-lang#128147, must not be merged before that PR.
1 parent 60d1465 commit f66adb0

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed
 

‎src/tools/run-make-support/src/external_deps/rustc.rs

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ impl Rustc {
194194
self
195195
}
196196

197+
/// Make `rustc` prefere dynamic linking
198+
pub fn prefer_dynamic(&mut self) -> &mut Self {
199+
self.arg("-Cprefer-dynamic")
200+
}
201+
197202
/// Specify directory path used for profile generation
198203
pub fn profile_generate<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
199204
let mut arg = OsString::new();

‎src/tools/run-make-support/src/symbols.rs

+26
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,29 @@ pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool
4242
false
4343
})
4444
}
45+
46+
/// Check if an object file contains *all* of the given symbols.
47+
///
48+
/// The symbol names must match exactly.
49+
///
50+
/// Panics if `path` is not a valid object file readable by the current user.
51+
pub fn contains_exact_symbols(path: impl AsRef<Path>, symbol_names: &[&str]) -> bool {
52+
let mut found = vec![false; symbol_names.len()];
53+
with_symbol_iter(path, |syms| {
54+
for sym in syms {
55+
for (i, symbol_name) in symbol_names.iter().enumerate() {
56+
found[i] |= sym.name_bytes().unwrap() == symbol_name.as_bytes();
57+
}
58+
}
59+
});
60+
let result = found.iter().all(|x| *x);
61+
if !result {
62+
eprintln!("does not contain symbol(s): ");
63+
for i in 0..found.len() {
64+
if !found[i] {
65+
eprintln!("* {}", symbol_names[i]);
66+
}
67+
}
68+
}
69+
result
70+
}

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ run-make/dep-info-doesnt-run-much/Makefile
55
run-make/dep-info-spaces/Makefile
66
run-make/dep-info/Makefile
77
run-make/emit-to-stdout/Makefile
8-
run-make/extern-fn-reachable/Makefile
98
run-make/incr-add-rust-src-component/Makefile
109
run-make/issue-84395-lto-embed-bitcode/Makefile
1110
run-make/jobserver-error/Makefile

‎tests/run-make/extern-fn-reachable/Makefile

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ ignore-cross-compile
2+
use run_make_support::{rustc, symbols::contains_exact_symbols};
3+
4+
fn main() {
5+
rustc().input("dylib.rs").output("dylib.so").prefer_dynamic().run();
6+
assert!(contains_exact_symbols("dylib.so", &["fun1", "fun2", "fun3", "fun4", "fun5"]));
7+
}

0 commit comments

Comments
 (0)
Failed to load comments.