Skip to content

Commit eea6502

Browse files
committed
Use llvm-readobj for run-make/crate-hash-rustc-version
1 parent ec6e07b commit eea6502

File tree

1 file changed

+14
-4
lines changed
  • tests/run-make/crate-hash-rustc-version

1 file changed

+14
-4
lines changed

tests/run-make/crate-hash-rustc-version/rmake.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@
44
//@ ignore-cross-compile
55
//@ only-unix
66

7-
use run_make_support::{cmd, diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};
7+
use run_make_support::llvm;
8+
use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};
9+
10+
fn llvm_readobj() -> llvm::LlvmReadobj {
11+
let mut cmd = llvm::llvm_readobj();
12+
if is_darwin() {
13+
cmd.symbols();
14+
} else {
15+
cmd.dynamic_table();
16+
}
17+
cmd
18+
}
819

920
fn main() {
1021
let flags = ["-Cprefer-dynamic", "-Csymbol-mangling-version=v0"];
11-
let nm_flag = if is_darwin() { [].as_slice() } else { ["-D"].as_slice() };
1222

1323
// a.rs is compiled to a dylib
1424
rustc().input("a.rs").crate_type("dylib").args(&flags).run();
1525

1626
// Store symbols
17-
let symbols_before = cmd("nm").args(nm_flag).arg(dynamic_lib_name("a")).run().stdout_utf8();
27+
let symbols_before = llvm_readobj().arg(dynamic_lib_name("a")).run().stdout_utf8();
1828

1929
// b.rs is compiled to a binary
2030
rustc()
@@ -35,7 +45,7 @@ fn main() {
3545
.run();
3646

3747
// After compiling with a different rustc version, store symbols again.
38-
let symbols_after = cmd("nm").args(nm_flag).arg(dynamic_lib_name("a")).run().stdout_utf8();
48+
let symbols_after = llvm_readobj().arg(dynamic_lib_name("a")).run().stdout_utf8();
3949

4050
// As a sanity check, test if the symbols changed:
4151
// If the symbols are identical, there's been an error.

0 commit comments

Comments
 (0)