Skip to content

Commit

Permalink
Unrolled build for rust-lang#127693
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#127693 - Rejyr:migrate-crate-hash-rustc-version-rmake, r=jieyouxu

Migrate `crate-hash-rustc-version` to `rmake`

Part of rust-lang#121876.

r? ``@jieyouxu``

try-job: x86_64-gnu-llvm-18
try-job: dist-x86_64-linux
  • Loading branch information
rust-timer committed Jul 20, 2024
2 parents 41ff460 + eea6502 commit 94d4fdf
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 39 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/compiler-lookup-paths-2/Makefile
run-make/compiler-rt-works-on-mingw/Makefile
run-make/crate-hash-rustc-version/Makefile
run-make/cross-lang-lto-clang/Makefile
run-make/cross-lang-lto-pgo-smoketest/Makefile
run-make/cross-lang-lto-upstream-rlibs/Makefile
Expand Down
38 changes: 0 additions & 38 deletions tests/run-make/crate-hash-rustc-version/Makefile

This file was deleted.

57 changes: 57 additions & 0 deletions tests/run-make/crate-hash-rustc-version/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Ensure that crates compiled with different rustc versions cannot
// be dynamically linked.

//@ ignore-cross-compile
//@ only-unix

use run_make_support::llvm;
use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};

fn llvm_readobj() -> llvm::LlvmReadobj {
let mut cmd = llvm::llvm_readobj();
if is_darwin() {
cmd.symbols();
} else {
cmd.dynamic_table();
}
cmd
}

fn main() {
let flags = ["-Cprefer-dynamic", "-Csymbol-mangling-version=v0"];

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

// Store symbols
let symbols_before = llvm_readobj().arg(dynamic_lib_name("a")).run().stdout_utf8();

// b.rs is compiled to 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, store symbols again.
let symbols_after = llvm_readobj().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");
}

0 comments on commit 94d4fdf

Please sign in to comment.