Skip to content

Commit 3f904e0

Browse files
committed
Migrate crate-hash-rustc-version to rmake
1 parent c1e3f03 commit 3f904e0

File tree

3 files changed

+46
-39
lines changed

3 files changed

+46
-39
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ run-make/cdylib-dylib-linkage/Makefile
1212
run-make/compiler-lookup-paths-2/Makefile
1313
run-make/compiler-lookup-paths/Makefile
1414
run-make/compiler-rt-works-on-mingw/Makefile
15-
run-make/crate-hash-rustc-version/Makefile
1615
run-make/cross-lang-lto-clang/Makefile
1716
run-make/cross-lang-lto-pgo-smoketest/Makefile
1817
run-make/cross-lang-lto-upstream-rlibs/Makefile

tests/run-make/crate-hash-rustc-version/Makefile

-38
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Ensure that crates compiled with different rustc versions cannot
2+
// be dynamically linked.
3+
4+
//@ ignore-cross-compile
5+
6+
use run_make_support::{cmd, diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};
7+
8+
fn main() {
9+
let flags = ["-Cprefer-dynamic", "-Csymbol-mangling-version=v0"];
10+
let nm_flag = if is_darwin() { ["-D"].as_slice() } else { [].as_slice() };
11+
12+
// a.rs is a dylib
13+
rustc().input("a.rs").crate_type("dylib").args(&flags).run();
14+
15+
// Write symbols to disk.
16+
let symbols_before = cmd("nm").args(nm_flag).arg(&dynamic_lib_name("a")).run().stdout_utf8();
17+
18+
// b.rs is a binary
19+
rustc()
20+
.input("b.rs")
21+
.extern_("a", dynamic_lib_name("a"))
22+
.crate_type("bin")
23+
.arg("-Crpath")
24+
.args(&flags)
25+
.run();
26+
run("b");
27+
28+
// Now re-compile a.rs with another rustc version
29+
rustc()
30+
.env("RUSTC_FORCE_RUSTC_VERSION", "deadfeed")
31+
.input("a.rs")
32+
.crate_type("dylib")
33+
.args(&flags)
34+
.run();
35+
36+
// After compiling with a different rustc version, write symbols to disk again.
37+
let symbols_after = cmd("nm").args(nm_flag).arg(&dynamic_lib_name("a")).run().stdout_utf8();
38+
39+
// As a sanity check, test if the symbols changed:
40+
// If the symbols are identical, there's been an error.
41+
diff()
42+
.expected_text("symbols_before", symbols_before)
43+
.actual_text("symbols_after", symbols_after)
44+
.run_fail();
45+
run_fail("b");
46+
}

0 commit comments

Comments
 (0)