Skip to content

Commit 47243b3

Browse files
committed
Auto merge of rust-lang#128065 - Oneirical:great-testilence, r=jieyouxu
Migrate `c-unwind-abi-catch-lib-panic`, `foreign-rust-exceptions` and `export-executable-symbols` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: aarch64-apple try-job: i686-mingw
2 parents 2d5a628 + 3cc1056 commit 47243b3

File tree

7 files changed

+84
-62
lines changed

7 files changed

+84
-62
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
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
@@ -10,12 +9,10 @@ run-make/dep-info-doesnt-run-much/Makefile
109
run-make/dep-info-spaces/Makefile
1110
run-make/dep-info/Makefile
1211
run-make/emit-to-stdout/Makefile
13-
run-make/export-executable-symbols/Makefile
1412
run-make/extern-fn-reachable/Makefile
1513
run-make/fmt-write-bloat/Makefile
1614
run-make/foreign-double-unwind/Makefile
1715
run-make/foreign-exceptions/Makefile
18-
run-make/foreign-rust-exceptions/Makefile
1916
run-make/incr-add-rust-src-component/Makefile
2017
run-make/issue-35164/Makefile
2118
run-make/issue-36710/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, 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+
}

tests/run-make/export-executable-symbols/Makefile

-11
This file was deleted.
Original file line numberDiff line numberDiff 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+
}

tests/run-make/foreign-rust-exceptions/Makefile

-13
This file was deleted.
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)