about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-30 14:20:16 -0400
committerOneirical <manchot@videotron.ca>2024-08-14 10:33:41 -0400
commit5e04cefb01151aa8b09ef311d043cffde0a514ca (patch)
tree43929baad623fcbf6363dee332fd85e51f447170 /tests
parent0f442e265c165c0a78633bef98de18517815150c (diff)
downloadrust-5e04cefb01151aa8b09ef311d043cffde0a514ca.tar.gz
rust-5e04cefb01151aa8b09ef311d043cffde0a514ca.zip
rewrite min-global-align to rmake
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/min-global-align/Makefile22
-rw-r--r--tests/run-make/min-global-align/rmake.rs27
2 files changed, 27 insertions, 22 deletions
diff --git a/tests/run-make/min-global-align/Makefile b/tests/run-make/min-global-align/Makefile
deleted file mode 100644
index 82f38749e00..00000000000
--- a/tests/run-make/min-global-align/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-include ../tools.mk
-
-# only-linux
-
-# This tests ensure that global variables respect the target minimum alignment.
-# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
-# type-alignment of 1, but some targets require greater global alignment.
-
-SRC = min_global_align.rs
-LL = $(TMPDIR)/min_global_align.ll
-
-all:
-# Most targets are happy with default alignment -- take i686 for example.
-ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
-	$(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC)
-	[ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ]
-endif
-# SystemZ requires even alignment for PC-relative addressing.
-ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
-	$(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC)
-	[ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ]
-endif
diff --git a/tests/run-make/min-global-align/rmake.rs b/tests/run-make/min-global-align/rmake.rs
new file mode 100644
index 00000000000..0db82b8340d
--- /dev/null
+++ b/tests/run-make/min-global-align/rmake.rs
@@ -0,0 +1,27 @@
+// This tests ensure that global variables respect the target minimum alignment.
+// The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
+// type-alignment of 1, but some targets require greater global alignment.
+// See https://github.com/rust-lang/rust/pull/44440
+
+//@ only-linux
+// Reason: this test is target-independent, considering compilation is targeted
+// towards linux architectures only.
+
+use run_make_support::{assert_count_is, llvm_components_contain, rfs, rustc};
+
+fn main() {
+    // Most targets are happy with default alignment -- take i686 for example.
+    if llvm_components_contain("x86") {
+        rustc().target("i686-unknown-linux-gnu").emit("llvm-ir").input("min_global_align.rs").run();
+        assert_count_is(3, rfs::read_to_string("min_global_align.ll"), "align 1");
+    }
+    // SystemZ requires even alignment for PC-relative addressing.
+    if llvm_components_contain("systemz") {
+        rustc()
+            .target("s390x-unknown-linux-gnu")
+            .emit("llvm-ir")
+            .input("min_global_align.rs")
+            .run();
+        assert_count_is(3, rfs::read_to_string("min_global_align.ll"), "align 2");
+    }
+}