Skip to content

Commit 959b44f

Browse files
committed
Auto merge of #127693 - Rejyr:migrate-crate-hash-rustc-version-rmake, r=<try>
Migrate `crate-hash-rustc-version` to `rmake` Part of #121876. r? `@jieyouxu` try-job: x86_64-msvc try-job: aarch64-apple try-job: dist-x86_64-linux
2 parents 5c84886 + 50f3293 commit 959b44f

File tree

3 files changed

+56
-39
lines changed

3 files changed

+56
-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,56 @@
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::llvm;
7+
use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};
8+
9+
fn llvm_readobj() -> llvm::LlvmReadobj {
10+
let mut cmd = llvm::llvm_readobj();
11+
if is_darwin() {
12+
cmd.symbols();
13+
} else {
14+
cmd.dynamic_table();
15+
}
16+
cmd
17+
}
18+
19+
fn main() {
20+
let flags = ["-Cprefer-dynamic", "-Csymbol-mangling-version=v0"];
21+
22+
// a.rs is compiled to a dylib
23+
rustc().input("a.rs").crate_type("dylib").args(&flags).run();
24+
25+
// Store symbols
26+
let symbols_before = llvm_readobj().arg(dynamic_lib_name("a")).run().stdout_utf8();
27+
28+
// b.rs is compiled to a binary
29+
rustc()
30+
.input("b.rs")
31+
.extern_("a", dynamic_lib_name("a"))
32+
.crate_type("bin")
33+
.arg("-Crpath")
34+
.args(&flags)
35+
.run();
36+
run("b");
37+
38+
// Now re-compile a.rs with another rustc version
39+
rustc()
40+
.env("RUSTC_FORCE_RUSTC_VERSION", "deadfeed")
41+
.input("a.rs")
42+
.crate_type("dylib")
43+
.args(&flags)
44+
.run();
45+
46+
// After compiling with a different rustc version, store symbols again.
47+
let symbols_after = llvm_readobj().arg(dynamic_lib_name("a")).run().stdout_utf8();
48+
49+
// As a sanity check, test if the symbols changed:
50+
// If the symbols are identical, there's been an error.
51+
diff()
52+
.expected_text("symbols_before", symbols_before)
53+
.actual_text("symbols_after", symbols_after)
54+
.run_fail();
55+
run_fail("b");
56+
}

0 commit comments

Comments
 (0)