about summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-13 16:10:49 -0400
committerOneirical <manchot@videotron.ca>2024-06-14 10:02:39 -0400
commitff82e43ca3dfc91e85c15070f836ca9cd692a476 (patch)
treec62b36facacbdbb99b6450143b810ebdbb0fa9d2 /tests/run-make
parentf9515fdd5aa132e27d9b580a35b27f4b453251c1 (diff)
downloadrust-ff82e43ca3dfc91e85c15070f836ca9cd692a476.tar.gz
rust-ff82e43ca3dfc91e85c15070f836ca9cd692a476.zip
rewrite and rename issue-64153 to rmake.rs
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/issue-64153/Makefile26
-rw-r--r--tests/run-make/lto-avoid-object-duplication/downstream.rs (renamed from tests/run-make/issue-64153/downstream.rs)0
-rw-r--r--tests/run-make/lto-avoid-object-duplication/rmake.rs37
-rw-r--r--tests/run-make/lto-avoid-object-duplication/upstream.rs (renamed from tests/run-make/issue-64153/upstream.rs)0
4 files changed, 37 insertions, 26 deletions
diff --git a/tests/run-make/issue-64153/Makefile b/tests/run-make/issue-64153/Makefile
deleted file mode 100644
index f42ea620fb9..00000000000
--- a/tests/run-make/issue-64153/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-include ../tools.mk
-
-# `llvm-objdump`'s output looks different on windows than on other platforms.
-# It should be enough to check on Unix platforms, so:
-# ignore-windows
-
-# Staticlibs don't include Rust object files from upstream crates if the same
-# code was already pulled into the lib via LTO. However, the bug described in
-# https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not
-# working properly if the upstream crate was compiled with an explicit filename
-# (via `-o`).
-#
-# This test makes sure that functions defined in the upstream crates do not
-# appear twice in the final staticlib when listing all the symbols from it.
-
-all:
-	$(RUSTC) --crate-type rlib upstream.rs -o $(TMPDIR)/libupstream.rlib -Ccodegen-units=1
-	$(RUSTC) --crate-type staticlib downstream.rs -Clto -Ccodegen-units=1 -o $(TMPDIR)/libdownstream.a
-	# Dump all the symbols from the staticlib into `syms`
-	"$(LLVM_BIN_DIR)"/llvm-objdump -t $(TMPDIR)/libdownstream.a > $(TMPDIR)/syms
-	# Count the global instances of `issue64153_test_function`. There'll be 2
-	# if the `upstream` object file got erroneously included twice.
-	# The line we are testing for with the regex looks something like:
-	# 0000000000000000 g     F .text.issue64153_test_function	00000023 issue64153_test_function
-	grep -c -e "[[:space:]]g[[:space:]]*F[[:space:]].*issue64153_test_function" $(TMPDIR)/syms > $(TMPDIR)/count
-	[ "$$(cat $(TMPDIR)/count)" -eq "1" ]
diff --git a/tests/run-make/issue-64153/downstream.rs b/tests/run-make/lto-avoid-object-duplication/downstream.rs
index e03704665d4..e03704665d4 100644
--- a/tests/run-make/issue-64153/downstream.rs
+++ b/tests/run-make/lto-avoid-object-duplication/downstream.rs
diff --git a/tests/run-make/lto-avoid-object-duplication/rmake.rs b/tests/run-make/lto-avoid-object-duplication/rmake.rs
new file mode 100644
index 00000000000..018e6a25b92
--- /dev/null
+++ b/tests/run-make/lto-avoid-object-duplication/rmake.rs
@@ -0,0 +1,37 @@
+// Staticlibs don't include Rust object files from upstream crates if the same
+// code was already pulled into the lib via LTO. However, the bug described in
+// https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not
+// working properly if the upstream crate was compiled with an explicit filename
+// (via `-o`).
+
+// This test makes sure that functions defined in the upstream crates do not
+// appear twice in the final staticlib when listing all the symbols from it.
+
+//@ ignore-windows
+// Reason: `llvm-objdump`'s output looks different on windows than on other platforms.
+// Only checking on Unix platforms should suffice.
+
+use run_make_support::{llvm_objdump, regex, rust_lib_name, rustc, static_lib_name};
+
+fn main() {
+    rustc()
+        .crate_type("rlib")
+        .input("upstream.rs")
+        .output(rust_lib_name("upstream"))
+        .codegen_units(1)
+        .run();
+    rustc()
+        .crate_type("staticlib")
+        .input("downstream.rs")
+        .arg("-Clto")
+        .output(static_lib_name("downstream"))
+        .codegen_units(1)
+        .run();
+    let syms = llvm_objdump().arg("-t").input(static_lib_name("downstream")).run().stdout_utf8();
+    let re = regex::Regex::new(r#"(?m)\s*g\s*F\s.*issue64153_test_function"#).unwrap();
+    // Count the global instances of `issue64153_test_function`. There'll be 2
+    // if the `upstream` object file got erroneously included twice.
+    // The line we are testing for with the regex looks something like:
+    // 0000000000000000 g     F .text.issue64153_test_function	00000023 issue64153_test_function
+    assert_eq!(re.find_iter(syms.as_str()).count(), 1);
+}
diff --git a/tests/run-make/issue-64153/upstream.rs b/tests/run-make/lto-avoid-object-duplication/upstream.rs
index 861a00298ea..861a00298ea 100644
--- a/tests/run-make/issue-64153/upstream.rs
+++ b/tests/run-make/lto-avoid-object-duplication/upstream.rs