about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-07-22 11:45:38 -0400
committerOneirical <manchot@videotron.ca>2024-07-26 10:17:03 -0400
commite2dbba8d4d4fe42e38e8db61a5801d719f577c79 (patch)
treec3c12f9ac826e67d0b511042d6db93d63199590d
parent355efacf0d430331c962a38af39049b76bb6266b (diff)
downloadrust-e2dbba8d4d4fe42e38e8db61a5801d719f577c79.tar.gz
rust-e2dbba8d4d4fe42e38e8db61a5801d719f577c79.zip
rewrite c-unwind-abi-catch-lib-panic to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/c-unwind-abi-catch-lib-panic/Makefile35
-rw-r--r--tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs36
3 files changed, 36 insertions, 36 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index fa340a02213..469bec31e47 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -1,5 +1,4 @@
 run-make/branch-protection-check-IBT/Makefile
-run-make/c-unwind-abi-catch-lib-panic/Makefile
 run-make/cat-and-grep-sanity-check/Makefile
 run-make/cdylib-dylib-linkage/Makefile
 run-make/cross-lang-lto-clang/Makefile
diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile b/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile
deleted file mode 100644
index 2bb8d42495d..00000000000
--- a/tests/run-make/c-unwind-abi-catch-lib-panic/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-# Exercise unwinding a panic. This catches a panic across an FFI boundary and downcasts it into an integer. The Rust code that panics is in a separate crate.
-# See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb
-
-# ignore-cross-compile
-# needs-unwind
-include ../tools.mk
-
-all: archive
-	# Compile `main.rs`, which will link into our library, and run it.
-	$(RUSTC) main.rs
-	$(call RUN,main)
-
-ifdef IS_MSVC
-archive: add.o panic.o
-	# Now, create an archive using these two objects.
-	$(AR) crus $(TMPDIR)/add.lib $(TMPDIR)/add.o $(TMPDIR)/panic.o
-else
-archive: add.o panic.o
-	# Now, create an archive using these two objects.
-	$(AR) crus $(TMPDIR)/libadd.a $(TMPDIR)/add.o $(TMPDIR)/panic.o
-endif
-
-# Compile `panic.rs` into an object file.
-#
-# Note that we invoke `rustc` directly, so we may emit an object rather
-# than an archive. We'll do that later.
-panic.o:
-	$(BARE_RUSTC) $(RUSTFLAGS)  \
-		--out-dir $(TMPDIR) \
-		--emit=obj panic.rs
-
-# Compile `add.c` into an object file.
-add.o:
-	$(call COMPILE_OBJ,$(TMPDIR)/add.o,add.c)
-
diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs
new file mode 100644
index 00000000000..4bdb8579af5
--- /dev/null
+++ b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs
@@ -0,0 +1,36 @@
+// Exercise unwinding a panic. This catches a panic across an FFI (foreign function interface)
+// boundary and downcasts it into an integer.
+// The Rust code that panics is in a separate crate.
+// See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb
+
+//@ ignore-cross-compile
+// Reason: the compiled binary is executed
+//@ needs-unwind
+// Reason: this test exercises unwinding a panic
+
+use run_make_support::{cc, is_msvc, llvm_ar, run, rustc};
+
+fn main() {
+    // Compile `add.c` into an object file.
+    if is_msvc() {
+        cc().arg("-c").out_exe("add").input("add.c").run();
+    } else {
+        cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run();
+    };
+
+    // Compile `panic.rs` into an object file.
+    // Note that we invoke `rustc` directly, so we may emit an object rather
+    // than an archive. We'll do that later.
+    rustc().emit("obj").input("panic.rs").run();
+
+    // Now, create an archive using these two objects.
+    if is_msvc() {
+        llvm_ar().obj_to_ar().args(&["libadd.a", "add.obj", "panic.o"]).run();
+    } else {
+        llvm_ar().obj_to_ar().args(&["libadd.a", "add.o", "panic.o"]).run();
+    };
+
+    // Compile `main.rs`, which will link into our library, and run it.
+    rustc().input("main.rs").run();
+    run("main");
+}