forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#127693 - Rejyr:migrate-crate-hash-rustc-versi…
…on-rmake, r=<try> Migrate `crate-hash-rustc-version` to `rmake` Part of rust-lang#121876. r? `@jieyouxu` try-job: x86_64-msvc try-job: aarch64-apple try-job: dist-x86_64-linux
- Loading branch information
Showing
3 changed files
with
46 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Ensure that crates compiled with different rustc versions cannot | ||
// be dynamically linked. | ||
|
||
//@ ignore-cross-compile | ||
|
||
use run_make_support::{cmd, diff, dynamic_lib_name, is_darwin, run, run_fail, rustc}; | ||
|
||
fn main() { | ||
let flags = ["-Cprefer-dynamic", "-Csymbol-mangling-version=v0"]; | ||
let nm_flag = if is_darwin() { ["-D"].as_slice() } else { [].as_slice() }; | ||
|
||
// a.rs is a dylib | ||
rustc().input("a.rs").crate_type("dylib").args(&flags).run(); | ||
|
||
// Write symbols to disk. | ||
let symbols_before = cmd("nm").args(nm_flag).arg(&dynamic_lib_name("a")).run().stdout_utf8(); | ||
|
||
// b.rs is a binary | ||
rustc() | ||
.input("b.rs") | ||
.extern_("a", dynamic_lib_name("a")) | ||
.crate_type("bin") | ||
.arg("-Crpath") | ||
.args(&flags) | ||
.run(); | ||
run("b"); | ||
|
||
// Now re-compile a.rs with another rustc version | ||
rustc() | ||
.env("RUSTC_FORCE_RUSTC_VERSION", "deadfeed") | ||
.input("a.rs") | ||
.crate_type("dylib") | ||
.args(&flags) | ||
.run(); | ||
|
||
// After compiling with a different rustc version, write symbols to disk again. | ||
let symbols_after = cmd("nm").args(nm_flag).arg(&dynamic_lib_name("a")).run().stdout_utf8(); | ||
|
||
// As a sanity check, test if the symbols changed: | ||
// If the symbols are identical, there's been an error. | ||
diff() | ||
.expected_text("symbols_before", symbols_before) | ||
.actual_text("symbols_after", symbols_after) | ||
.run_fail(); | ||
run_fail("b"); | ||
} |