Skip to content

Commit

Permalink
Auto merge of #128065 - Oneirical:great-testilence, r=<try>
Browse files Browse the repository at this point in the history
Migrate `c-unwind-abi-catch-lib-panic`, `foreign-rust-exceptions` and `export-executable-symbols` `run-make` tests to rmake

Part of #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
  • Loading branch information
bors committed Jul 23, 2024
2 parents d53dc75 + cafac2c commit 02295fe
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 62 deletions.
3 changes: 0 additions & 3 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
run-make/branch-protection-check-IBT/Makefile
run-make/c-dynamic-dylib/Makefile
run-make/c-dynamic-rlib/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/compiler-rt-works-on-mingw/Makefile
Expand All @@ -14,7 +13,6 @@ run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/emit-to-stdout/Makefile
run-make/export-executable-symbols/Makefile
run-make/extern-diff-internal-name/Makefile
run-make/extern-flag-disambiguates/Makefile
run-make/extern-fn-reachable/Makefile
Expand All @@ -23,7 +21,6 @@ run-make/extern-multiple-copies2/Makefile
run-make/fmt-write-bloat/Makefile
run-make/foreign-double-unwind/Makefile
run-make/foreign-exceptions/Makefile
run-make/foreign-rust-exceptions/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
run-make/interdependent-c-libraries/Makefile
Expand Down
35 changes: 0 additions & 35 deletions tests/run-make/c-unwind-abi-catch-lib-panic/Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs
Original file line number Diff line number Diff line change
@@ -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, 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");
}
11 changes: 0 additions & 11 deletions tests/run-make/export-executable-symbols/Makefile

This file was deleted.

25 changes: 25 additions & 0 deletions tests/run-make/export-executable-symbols/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The unstable flag `-Z export-executable-symbols` exports symbols from executables, as if
// they were dynamic libraries. This test is a simple smoke test to check that this feature
// works by using it in compilation, then checking that the output binary contains the exported
// symbol.
// See https://github.com/rust-lang/rust/pull/85673

//@ only-unix
// Reason: the export-executable-symbols flag only works on Unix
// due to hardcoded platform-specific implementation
// (See #85673)
//@ ignore-wasm32
//@ ignore-wasm64
//@ ignore-none
// Reason: no-std is not supported

use run_make_support::{bin_name, llvm_readobj, rustc};

fn main() {
rustc().arg("-Zexport-executable-symbols").input("main.rs").crate_type("bin").run();
llvm_readobj()
.symbols()
.input(bin_name("main"))
.run()
.assert_stdout_contains("exported_symbol");
}
13 changes: 0 additions & 13 deletions tests/run-make/foreign-rust-exceptions/Makefile

This file was deleted.

23 changes: 23 additions & 0 deletions tests/run-make/foreign-rust-exceptions/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Rust exceptions can be foreign (from C code, in this test) or local. Foreign
// exceptions should not be caught, as that can cause undefined behaviour. Instead
// of catching them, #102721 made it so that the binary panics in execution with a helpful message.
// This test checks that the correct message appears and that execution fails when trying to catch
// a foreign exception.
// See https://github.com/rust-lang/rust/issues/102715

//@ ignore-cross-compile
// Reason: the compiled binary is executed
//@ needs-unwind
// Reason: unwinding panics is exercised in this test

//FIXME(Oneirical): ignore-i686-pc-windows-gnu
// This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder
// so cross-DLL unwinding does not work.

use run_make_support::{run_fail, rustc};

fn main() {
rustc().input("bar.rs").crate_type("cdylib").run();
rustc().input("foo.rs").run();
run_fail("foo").assert_stderr_contains("Rust cannot catch foreign exceptions");
}

0 comments on commit 02295fe

Please sign in to comment.