| author | bors <bors@rust-lang.org> 2024-07-26 16:21:41 UTC |
| committer | bors <bors@rust-lang.org> 2024-07-26 16:21:41 UTC |
| log | 47243b335e02c341528dd3beb77fa0e030d7ccda |
| tree | 7341890cc1fbe8d504f5dee27458b31d705f5ecd |
| parent | 2d5a628a1de1d38318909a710ef37da6251e362e |
| parent | 3cc1056ff77a9a6fb338549b712aebfef1959be0 |
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-mingw7 files changed, 84 insertions(+), 62 deletions(-)
src/tools/tidy/src/allowed_run_make_makefiles.txt-3| ... | @@ -1,5 +1,4 @@ | ... | @@ -1,5 +1,4 @@ |
| 1 | run-make/branch-protection-check-IBT/Makefile | 1 | run-make/branch-protection-check-IBT/Makefile |
| 2 | run-make/c-unwind-abi-catch-lib-panic/Makefile | ||
| 3 | run-make/cat-and-grep-sanity-check/Makefile | 2 | run-make/cat-and-grep-sanity-check/Makefile |
| 4 | run-make/cdylib-dylib-linkage/Makefile | 3 | run-make/cdylib-dylib-linkage/Makefile |
| 5 | run-make/cross-lang-lto-clang/Makefile | 4 | run-make/cross-lang-lto-clang/Makefile |
| ... | @@ -10,12 +9,10 @@ run-make/dep-info-doesnt-run-much/Makefile | ... | @@ -10,12 +9,10 @@ run-make/dep-info-doesnt-run-much/Makefile |
| 10 | run-make/dep-info-spaces/Makefile | 9 | run-make/dep-info-spaces/Makefile |
| 11 | run-make/dep-info/Makefile | 10 | run-make/dep-info/Makefile |
| 12 | run-make/emit-to-stdout/Makefile | 11 | run-make/emit-to-stdout/Makefile |
| 13 | run-make/export-executable-symbols/Makefile | ||
| 14 | run-make/extern-fn-reachable/Makefile | 12 | run-make/extern-fn-reachable/Makefile |
| 15 | run-make/fmt-write-bloat/Makefile | 13 | run-make/fmt-write-bloat/Makefile |
| 16 | run-make/foreign-double-unwind/Makefile | 14 | run-make/foreign-double-unwind/Makefile |
| 17 | run-make/foreign-exceptions/Makefile | 15 | run-make/foreign-exceptions/Makefile |
| 18 | run-make/foreign-rust-exceptions/Makefile | ||
| 19 | run-make/incr-add-rust-src-component/Makefile | 16 | run-make/incr-add-rust-src-component/Makefile |
| 20 | run-make/issue-35164/Makefile | 17 | run-make/issue-35164/Makefile |
| 21 | run-make/issue-36710/Makefile | 18 | run-make/issue-36710/Makefile |
tests/run-make/c-unwind-abi-catch-lib-panic/Makefile deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | # Exercise unwinding a panic. This catches a panic across an FFI boundary and downcasts it into an integer. The Rust code that panics is in a separate crate. | ||
| 2 | # See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb | ||
| 3 | |||
| 4 | # ignore-cross-compile | ||
| 5 | # needs-unwind | ||
| 6 | include ../tools.mk | ||
| 7 | |||
| 8 | all: archive | ||
| 9 | 	# Compile `main.rs`, which will link into our library, and run it. | ||
| 10 | 	$(RUSTC) main.rs | ||
| 11 | 	$(call RUN,main) | ||
| 12 | |||
| 13 | ifdef IS_MSVC | ||
| 14 | archive: add.o panic.o | ||
| 15 | 	# Now, create an archive using these two objects. | ||
| 16 | 	$(AR) crus $(TMPDIR)/add.lib $(TMPDIR)/add.o $(TMPDIR)/panic.o | ||
| 17 | else | ||
| 18 | archive: add.o panic.o | ||
| 19 | 	# Now, create an archive using these two objects. | ||
| 20 | 	$(AR) crus $(TMPDIR)/libadd.a $(TMPDIR)/add.o $(TMPDIR)/panic.o | ||
| 21 | endif | ||
| 22 | |||
| 23 | # Compile `panic.rs` into an object file. | ||
| 24 | # | ||
| 25 | # Note that we invoke `rustc` directly, so we may emit an object rather | ||
| 26 | # than an archive. We'll do that later. | ||
| 27 | panic.o: | ||
| 28 | 	$(BARE_RUSTC) $(RUSTFLAGS) \ | ||
| 29 | 		--out-dir $(TMPDIR) \ | ||
| 30 | 		--emit=obj panic.rs | ||
| 31 | |||
| 32 | # Compile `add.c` into an object file. | ||
| 33 | add.o: | ||
| 34 | 	$(call COMPILE_OBJ,$(TMPDIR)/add.o,add.c) | ||
| 35 | |||
tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs created+36| ... | @@ -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 deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | include ../tools.mk | ||
| 2 | |||
| 3 | # ignore-wasm32 | ||
| 4 | # ignore-wasm64 | ||
| 5 | # ignore-none no-std is not supported | ||
| 6 | # only-linux | ||
| 7 | |||
| 8 | all: | ||
| 9 | 	$(RUSTC) -Zexport-executable-symbols main.rs --target $(TARGET) --crate-type=bin | ||
| 10 | 	nm $(TMPDIR)/main | $(CGREP) exported_symbol | ||
| 11 | |||
tests/run-make/export-executable-symbols/rmake.rs created+25| ... | @@ -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 deleted-13| ... | @@ -1,13 +0,0 @@ | ||
| 1 | # ignore-cross-compile | ||
| 2 | # ignore-i686-pc-windows-gnu | ||
| 3 | # needs-unwind | ||
| 4 | |||
| 5 | # This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder | ||
| 6 | # so cross-DLL unwinding does not work. | ||
| 7 | |||
| 8 | include ../tools.mk | ||
| 9 | |||
| 10 | all: | ||
| 11 | 	$(RUSTC) bar.rs --crate-type=cdylib | ||
| 12 | 	$(RUSTC) foo.rs | ||
| 13 | 	$(call RUN,foo) 2>&1 | $(CGREP) "Rust cannot catch foreign exceptions" | ||
tests/run-make/foreign-rust-exceptions/rmake.rs created+23| ... | @@ -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 | } | ||