Skip to content

Commit e2dbba8

Browse files
committed
rewrite c-unwind-abi-catch-lib-panic to rmake
1 parent 355efac commit e2dbba8

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
run-make/branch-protection-check-IBT/Makefile
2-
run-make/c-unwind-abi-catch-lib-panic/Makefile
32
run-make/cat-and-grep-sanity-check/Makefile
43
run-make/cdylib-dylib-linkage/Makefile
54
run-make/cross-lang-lto-clang/Makefile

tests/run-make/c-unwind-abi-catch-lib-panic/Makefile

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Exercise unwinding a panic. This catches a panic across an FFI (foreign function interface)
2+
// boundary and downcasts it into an integer.
3+
// The Rust code that panics is in a separate crate.
4+
// See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
//@ needs-unwind
9+
// Reason: this test exercises unwinding a panic
10+
11+
use run_make_support::{cc, is_msvc, llvm_ar, run, rustc};
12+
13+
fn main() {
14+
// Compile `add.c` into an object file.
15+
if is_msvc() {
16+
cc().arg("-c").out_exe("add").input("add.c").run();
17+
} else {
18+
cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run();
19+
};
20+
21+
// Compile `panic.rs` into an object file.
22+
// Note that we invoke `rustc` directly, so we may emit an object rather
23+
// than an archive. We'll do that later.
24+
rustc().emit("obj").input("panic.rs").run();
25+
26+
// Now, create an archive using these two objects.
27+
if is_msvc() {
28+
llvm_ar().obj_to_ar().args(&["libadd.a", "add.obj", "panic.o"]).run();
29+
} else {
30+
llvm_ar().obj_to_ar().args(&["libadd.a", "add.o", "panic.o"]).run();
31+
};
32+
33+
// Compile `main.rs`, which will link into our library, and run it.
34+
rustc().input("main.rs").run();
35+
run("main");
36+
}

0 commit comments

Comments
 (0)