rewrite metadata-flag-frobs-symbols to rmake

This commit is contained in:
Oneirical 2024-06-18 16:20:32 -04:00
parent 9e2ace85f9
commit dff354e57f
4 changed files with 27 additions and 12 deletions

View File

@ -73,6 +73,12 @@ impl Rustc {
self
}
/// Incorporate a hashed string to mangled symbols.
pub fn metadata(&mut self, meta: &str) -> &mut Self {
self.cmd.arg(format!("-Cmetadata={meta}"));
self
}
/// Add a suffix in each output filename.
pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
self.cmd.arg(format!("-Cextra-filename={suffix}"));

View File

@ -119,7 +119,6 @@ run-make/macos-fat-archive/Makefile
run-make/manual-link/Makefile
run-make/many-crates-but-no-match/Makefile
run-make/metadata-dep-info/Makefile
run-make/metadata-flag-frobs-symbols/Makefile
run-make/min-global-align/Makefile
run-make/mingw-export-call-convention/Makefile
run-make/mismatching-target-triples/Makefile

View File

@ -1,11 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) foo.rs -C metadata=a -C extra-filename=-a
$(RUSTC) foo.rs -C metadata=b -C extra-filename=-b
$(RUSTC) bar.rs \
--extern foo1=$(TMPDIR)/libfoo-a.rlib \
--extern foo2=$(TMPDIR)/libfoo-b.rlib \
--print link-args
$(call RUN,bar)

View File

@ -0,0 +1,21 @@
// In this test, foo.rs is compiled twice with different hashes tied to its
// symbols thanks to the metadata flag. bar.rs then ensures that the memory locations
// of foo's symbols are different even though they came from the same original source code.
// This checks that the metadata flag is doing its job.
// See https://github.com/rust-lang/rust/issues/14471
//@ ignore-cross-compile
use run_make_support::{run, rust_lib_name, rustc};
fn main() {
rustc().input("foo.rs").metadata("a").extra_filename("-a").run();
rustc().input("foo.rs").metadata("b").extra_filename("-b").run();
rustc()
.input("bar.rs")
.extern_("foo1", rust_lib_name("foo-a"))
.extern_("foo2", rust_lib_name("foo-b"))
.print("link-args")
.run();
run("bar");
}