about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-18 16:20:32 -0400
committerOneirical <manchot@videotron.ca>2024-06-18 16:20:32 -0400
commitdff354e57fe030f8fa0467f092b75e8979a3cce9 (patch)
treedb2bdaa5047e18275e7d58f00d5f2fcbb6fb2185
parent9e2ace85f9d2a9fd24af197f2da81eb3a5db51b9 (diff)
downloadrust-dff354e57fe030f8fa0467f092b75e8979a3cce9.tar.gz
rust-dff354e57fe030f8fa0467f092b75e8979a3cce9.zip
rewrite metadata-flag-frobs-symbols to rmake
-rw-r--r--src/tools/run-make-support/src/rustc.rs6
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/metadata-flag-frobs-symbols/Makefile11
-rw-r--r--tests/run-make/metadata-flag-frobs-symbols/rmake.rs21
4 files changed, 27 insertions, 12 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index 331e1a5ab8b..125f4b4bd62 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -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}"));
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 4091cbbbcb8..691248ea260 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -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
diff --git a/tests/run-make/metadata-flag-frobs-symbols/Makefile b/tests/run-make/metadata-flag-frobs-symbols/Makefile
deleted file mode 100644
index 53d7d065769..00000000000
--- a/tests/run-make/metadata-flag-frobs-symbols/Makefile
+++ /dev/null
@@ -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)
diff --git a/tests/run-make/metadata-flag-frobs-symbols/rmake.rs b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs
new file mode 100644
index 00000000000..12c07f9e3ae
--- /dev/null
+++ b/tests/run-make/metadata-flag-frobs-symbols/rmake.rs
@@ -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");
+}