Auto merge of #128065 - Oneirical:great-testilence, r=jieyouxu · rust-lang/rust@47243b3 (original) (raw)

File tree

7 files changed

lines changed

7 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
1 1 run-make/branch-protection-check-IBT/Makefile
2 -run-make/c-unwind-abi-catch-lib-panic/Makefile
3 2 run-make/cat-and-grep-sanity-check/Makefile
4 3 run-make/cdylib-dylib-linkage/Makefile
5 4 run-make/cross-lang-lto-clang/Makefile
@@ -10,12 +9,10 @@ run-make/dep-info-doesnt-run-much/Makefile
10 9 run-make/dep-info-spaces/Makefile
11 10 run-make/dep-info/Makefile
12 11 run-make/emit-to-stdout/Makefile
13 -run-make/export-executable-symbols/Makefile
14 12 run-make/extern-fn-reachable/Makefile
15 13 run-make/fmt-write-bloat/Makefile
16 14 run-make/foreign-double-unwind/Makefile
17 15 run-make/foreign-exceptions/Makefile
18 -run-make/foreign-rust-exceptions/Makefile
19 16 run-make/incr-add-rust-src-component/Makefile
20 17 run-make/issue-35164/Makefile
21 18 run-make/issue-36710/Makefile
Original file line number Diff line number Diff 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, static_lib_name};
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(&[&static_lib_name("add"), "add.obj", "panic.o"]).run();
29 +} else {
30 +llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "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 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1 +// The unstable flag `-Z export-executable-symbols` exports symbols from executables, as if
2 +// they were dynamic libraries. This test is a simple smoke test to check that this feature
3 +// works by using it in compilation, then checking that the output binary contains the exported
4 +// symbol.
5 +// See https://github.com/rust-lang/rust/pull/85673
6 +
7 +//@ only-unix
8 +// Reason: the export-executable-symbols flag only works on Unix
9 +// due to hardcoded platform-specific implementation
10 +// (See #85673)
11 +//@ ignore-wasm32
12 +//@ ignore-wasm64
13 +//@ ignore-none
14 +// Reason: no-std is not supported
15 +
16 +use run_make_support::{bin_name, llvm_readobj, rustc};
17 +
18 +fn main() {
19 +rustc().arg("-Zexport-executable-symbols").input("main.rs").crate_type("bin").run();
20 +llvm_readobj()
21 +.symbols()
22 +.input(bin_name("main"))
23 +.run()
24 +.assert_stdout_contains("exported_symbol");
25 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1 +// Rust exceptions can be foreign (from C code, in this test) or local. Foreign
2 +// exceptions should not be caught, as that can cause undefined behaviour. Instead
3 +// of catching them, #102721 made it so that the binary panics in execution with a helpful message.
4 +// This test checks that the correct message appears and that execution fails when trying to catch
5 +// a foreign exception.
6 +// See https://github.com/rust-lang/rust/issues/102715
7 +
8 +//@ ignore-cross-compile
9 +// Reason: the compiled binary is executed
10 +//@ needs-unwind
11 +// Reason: unwinding panics is exercised in this test
12 +
13 +//@ ignore-i686-pc-windows-gnu
14 +// Reason: This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder
15 +// so cross-DLL unwinding does not work.
16 +
17 +use run_make_support::{run_fail, rustc};
18 +
19 +fn main() {
20 +rustc().input("bar.rs").crate_type("cdylib").run();
21 +rustc().input("foo.rs").run();
22 +run_fail("foo").assert_stderr_contains("Rust cannot catch foreign exceptions");
23 +}