forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrmake.rs
More file actions
36 lines (30 loc) · 1.31 KB
/
Copy pathrmake.rs
File metadata and controls
36 lines (30 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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, static_lib_name};
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(&[&static_lib_name("add"), "add.obj", "panic.o"]).run();
} else {
llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.o", "panic.o"]).run();
};
// Compile `main.rs`, which will link into our library, and run it.
rustc().input("main.rs").run();
run("main");
}