From a47ca1913469e574369e6ddc28f124e5c9e9e13a Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 13:42:46 -0400 Subject: [PATCH 1/8] rewrite extern-fn-with-extern-types to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../extern-fn-with-extern-types/Makefile | 6 ------ .../extern-fn-with-extern-types/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-fn-with-extern-types/Makefile create mode 100644 tests/run-make/extern-fn-with-extern-types/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2e26f9344b899..e016d3f11398f 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -29,7 +29,6 @@ run-make/extern-fn-generic/Makefile run-make/extern-fn-mangle/Makefile run-make/extern-fn-reachable/Makefile run-make/extern-fn-struct-passing-abi/Makefile -run-make/extern-fn-with-extern-types/Makefile run-make/extern-fn-with-packed-struct/Makefile run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile diff --git a/tests/run-make/extern-fn-with-extern-types/Makefile b/tests/run-make/extern-fn-with-extern-types/Makefile deleted file mode 100644 index 07ec503aaaea5..0000000000000 --- a/tests/run-make/extern-fn-with-extern-types/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-with-extern-types/rmake.rs b/tests/run-make/extern-fn-with-extern-types/rmake.rs new file mode 100644 index 0000000000000..02521ae2cdb1d --- /dev/null +++ b/tests/run-make/extern-fn-with-extern-types/rmake.rs @@ -0,0 +1,16 @@ +// This test checks the functionality of foreign function interface (FFI) where Rust +// must call upon a C library defining functions, where these functions also use custom +// types defined by the C file. In addition to compilation being successful, the binary +// should also successfully execute. +// See https://github.com/rust-lang/rust/pull/44295 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("ctest"); + rustc().input("test.rs").run(); + run("test"); +} From a795d8998d6715044a4e28ffda90a251a780eae1 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 13:54:04 -0400 Subject: [PATCH 2/8] rewrite and rename issue-25581 --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/extern-fn-slice-no-ice/rmake.rs | 17 +++++++++++++++++ .../test.c | 0 .../test.rs | 0 tests/run-make/issue-25581/Makefile | 6 ------ 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 tests/run-make/extern-fn-slice-no-ice/rmake.rs rename tests/run-make/{issue-25581 => extern-fn-slice-no-ice}/test.c (100%) rename tests/run-make/{issue-25581 => extern-fn-slice-no-ice}/test.rs (100%) delete mode 100644 tests/run-make/issue-25581/Makefile diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index e016d3f11398f..5a7fe935e7096 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -44,7 +44,6 @@ run-make/issue-107094/Makefile run-make/issue-14698/Makefile run-make/issue-15460/Makefile run-make/issue-22131/Makefile -run-make/issue-25581/Makefile run-make/issue-26006/Makefile run-make/issue-28595/Makefile run-make/issue-33329/Makefile diff --git a/tests/run-make/extern-fn-slice-no-ice/rmake.rs b/tests/run-make/extern-fn-slice-no-ice/rmake.rs new file mode 100644 index 0000000000000..1f1bbd331273a --- /dev/null +++ b/tests/run-make/extern-fn-slice-no-ice/rmake.rs @@ -0,0 +1,17 @@ +// Slices were broken when implicated in foreign-function interface (FFI) with +// a C library, with something as simple as measuring the length or returning +// an item at a certain index of a slice would cause an internal compiler error (ICE). +// This was fixed in #25653, and this test checks that slices in Rust-C FFI can be part +// of a program that compiles and executes successfully. +// See https://github.com/rust-lang/rust/issues/25581 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("test.rs").run(); + run("test"); +} diff --git a/tests/run-make/issue-25581/test.c b/tests/run-make/extern-fn-slice-no-ice/test.c similarity index 100% rename from tests/run-make/issue-25581/test.c rename to tests/run-make/extern-fn-slice-no-ice/test.c diff --git a/tests/run-make/issue-25581/test.rs b/tests/run-make/extern-fn-slice-no-ice/test.rs similarity index 100% rename from tests/run-make/issue-25581/test.rs rename to tests/run-make/extern-fn-slice-no-ice/test.rs diff --git a/tests/run-make/issue-25581/Makefile b/tests/run-make/issue-25581/Makefile deleted file mode 100644 index 3cbbf3839969f..0000000000000 --- a/tests/run-make/issue-25581/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 From d6a3f65db099716fb03f056716d4114948bf7087 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 14:03:04 -0400 Subject: [PATCH 3/8] rewrite extern-fn-struct-passing-abi to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../extern-fn-struct-passing-abi/Makefile | 6 ------ .../extern-fn-struct-passing-abi/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-fn-struct-passing-abi/Makefile create mode 100644 tests/run-make/extern-fn-struct-passing-abi/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 5a7fe935e7096..645f489cb39c8 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -28,7 +28,6 @@ run-make/extern-fn-explicit-align/Makefile run-make/extern-fn-generic/Makefile run-make/extern-fn-mangle/Makefile run-make/extern-fn-reachable/Makefile -run-make/extern-fn-struct-passing-abi/Makefile run-make/extern-fn-with-packed-struct/Makefile run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile diff --git a/tests/run-make/extern-fn-struct-passing-abi/Makefile b/tests/run-make/extern-fn-struct-passing-abi/Makefile deleted file mode 100644 index 3cbbf3839969f..0000000000000 --- a/tests/run-make/extern-fn-struct-passing-abi/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-struct-passing-abi/rmake.rs b/tests/run-make/extern-fn-struct-passing-abi/rmake.rs new file mode 100644 index 0000000000000..5c4ddb7f58e65 --- /dev/null +++ b/tests/run-make/extern-fn-struct-passing-abi/rmake.rs @@ -0,0 +1,16 @@ +// Functions with more than 6 arguments using foreign function interfaces (FFI) with C libraries +// would have their arguments unexpectedly swapped, causing unexpected behaviour in Rust-C FFI +// programs. This test compiles and executes Rust code with bulky functions of up to 7 arguments +// and uses assertions to check for unexpected swaps. +// See https://github.com/rust-lang/rust/issues/25594 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("test.rs").run(); + run("test"); +} From 98454ece33fc282fbcb27b8f56764347d247798d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 14:15:01 -0400 Subject: [PATCH 4/8] rewrite longjmp-across-rust to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/longjmp-across-rust/Makefile | 6 ------ tests/run-make/longjmp-across-rust/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/longjmp-across-rust/Makefile create mode 100644 tests/run-make/longjmp-across-rust/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 645f489cb39c8..2f2af6b8bc1dc 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -65,7 +65,6 @@ run-make/link-path-order/Makefile run-make/linkage-attr-on-static/Makefile run-make/long-linker-command-lines-cmd-exe/Makefile run-make/long-linker-command-lines/Makefile -run-make/longjmp-across-rust/Makefile run-make/lto-linkage-used-attr/Makefile run-make/lto-no-link-whole-rlib/Makefile run-make/lto-smoke-c/Makefile diff --git a/tests/run-make/longjmp-across-rust/Makefile b/tests/run-make/longjmp-across-rust/Makefile deleted file mode 100644 index 5fd2d4f855ffe..0000000000000 --- a/tests/run-make/longjmp-across-rust/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) main.rs - $(call RUN,main) diff --git a/tests/run-make/longjmp-across-rust/rmake.rs b/tests/run-make/longjmp-across-rust/rmake.rs new file mode 100644 index 0000000000000..90a527077d21d --- /dev/null +++ b/tests/run-make/longjmp-across-rust/rmake.rs @@ -0,0 +1,18 @@ +// longjmp, an error handling function used in C, is useful +// for jumping out of nested call chains... but it used to accidentally +// trigger Rust's cleanup system in a way that caused an unexpected abortion +// of the program. After this was fixed in #48572, this test compiles and executes +// a program that jumps between Rust and its C library, with longjmp included. For +// the test to succeed, no unexpected abortion should occur. +// See https://github.com/rust-lang/rust/pull/48572 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("foo"); + rustc().input("main.rs").run(); + run("main"); +} From 205bfe72130fc9ea3eb646a5d3d59d0525b8d708 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 14:35:30 -0400 Subject: [PATCH 5/8] rewrite static-extern-type to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/static-extern-type/Makefile | 6 ------ tests/run-make/static-extern-type/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/static-extern-type/Makefile create mode 100644 tests/run-make/static-extern-type/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2f2af6b8bc1dc..51614f84ec360 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -108,7 +108,6 @@ run-make/simd-ffi/Makefile run-make/split-debuginfo/Makefile run-make/stable-symbol-names/Makefile run-make/static-dylib-by-default/Makefile -run-make/static-extern-type/Makefile run-make/staticlib-blank-lib/Makefile run-make/staticlib-dylib-linkage/Makefile run-make/symbol-mangling-hashed/Makefile diff --git a/tests/run-make/static-extern-type/Makefile b/tests/run-make/static-extern-type/Makefile deleted file mode 100644 index 778971543221e..0000000000000 --- a/tests/run-make/static-extern-type/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,define-foo) - $(RUSTC) -ldefine-foo use-foo.rs - $(call RUN,use-foo) || exit 1 diff --git a/tests/run-make/static-extern-type/rmake.rs b/tests/run-make/static-extern-type/rmake.rs new file mode 100644 index 0000000000000..d30153f9c6863 --- /dev/null +++ b/tests/run-make/static-extern-type/rmake.rs @@ -0,0 +1,16 @@ +// Static variables coming from a C library through foreign function interface (FFI) are unsized +// at compile time - and assuming they are sized used to cause an internal compiler error (ICE). +// After this was fixed in #58192, this test checks that external statics can be safely used in +// a program that both compiles and executes successfully. +// See https://github.com/rust-lang/rust/issues/57876 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("define-foo"); + rustc().arg("-ldefine-foo").input("use-foo.rs").run(); + run("use-foo"); +} From bde91785dc4de27787ac20074f3fda70ec47c88d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 14:51:01 -0400 Subject: [PATCH 6/8] rewrite extern-fn-explicit-align to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/extern-fn-explicit-align/Makefile | 6 ------ .../run-make/extern-fn-explicit-align/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-fn-explicit-align/Makefile create mode 100644 tests/run-make/extern-fn-explicit-align/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 51614f84ec360..fde065b929b94 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -24,7 +24,6 @@ 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-explicit-align/Makefile run-make/extern-fn-generic/Makefile run-make/extern-fn-mangle/Makefile run-make/extern-fn-reachable/Makefile diff --git a/tests/run-make/extern-fn-explicit-align/Makefile b/tests/run-make/extern-fn-explicit-align/Makefile deleted file mode 100644 index 3cbbf3839969f..0000000000000 --- a/tests/run-make/extern-fn-explicit-align/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-explicit-align/rmake.rs b/tests/run-make/extern-fn-explicit-align/rmake.rs new file mode 100644 index 0000000000000..fb153f92103b2 --- /dev/null +++ b/tests/run-make/extern-fn-explicit-align/rmake.rs @@ -0,0 +1,17 @@ +// The compiler's rules of alignment for indirectly passed values in a 16-byte aligned argument, +// in a C external function, used to be arbitrary. Unexpected behavior would occasionally occur +// and cause memory corruption. This was fixed in #112157, streamlining the way alignment occurs, +// and this test reproduces the case featured in the issue, checking that it compiles and executes +// successfully. +// See https://github.com/rust-lang/rust/issues/80127 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("test.rs").run(); + run("test"); +} From f7d67d6b6855d0f3880668f2f2d0dabc02caef31 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 14:57:07 -0400 Subject: [PATCH 7/8] rewrite extern-fn-with-packed-struct to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../extern-fn-with-packed-struct/Makefile | 6 ------ .../extern-fn-with-packed-struct/rmake.rs | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-fn-with-packed-struct/Makefile create mode 100644 tests/run-make/extern-fn-with-packed-struct/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index fde065b929b94..1c6fc57bd818c 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -27,7 +27,6 @@ run-make/extern-flag-disambiguates/Makefile run-make/extern-fn-generic/Makefile run-make/extern-fn-mangle/Makefile run-make/extern-fn-reachable/Makefile -run-make/extern-fn-with-packed-struct/Makefile run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile run-make/extern-multiple-copies2/Makefile diff --git a/tests/run-make/extern-fn-with-packed-struct/Makefile b/tests/run-make/extern-fn-with-packed-struct/Makefile deleted file mode 100644 index 3cbbf3839969f..0000000000000 --- a/tests/run-make/extern-fn-with-packed-struct/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-with-packed-struct/rmake.rs b/tests/run-make/extern-fn-with-packed-struct/rmake.rs new file mode 100644 index 0000000000000..e6d8cecd24a2b --- /dev/null +++ b/tests/run-make/extern-fn-with-packed-struct/rmake.rs @@ -0,0 +1,17 @@ +// Packed structs, in C, occupy less bytes in memory, but are more +// vulnerable to alignment errors. Passing them around in a Rust-C foreign +// function interface (FFI) would cause unexpected behavior, until this was +// fixed in #16584. This test checks that a Rust program with a C library +// compiles and executes successfully, even with usage of a packed struct. +// See https://github.com/rust-lang/rust/issues/16574 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("test.rs").run(); + run("test"); +} From c68d25b0977b5415fdffb48c381ee1c49fb31322 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 8 Jul 2024 15:06:16 -0400 Subject: [PATCH 8/8] rewrite extern-fn-mangle to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/extern-fn-mangle/Makefile | 6 ------ tests/run-make/extern-fn-mangle/rmake.rs | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) delete mode 100644 tests/run-make/extern-fn-mangle/Makefile create mode 100644 tests/run-make/extern-fn-mangle/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 1c6fc57bd818c..2c272706e7dfc 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -25,7 +25,6 @@ run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile run-make/extern-flag-disambiguates/Makefile run-make/extern-fn-generic/Makefile -run-make/extern-fn-mangle/Makefile run-make/extern-fn-reachable/Makefile run-make/extern-fn-with-union/Makefile run-make/extern-multiple-copies/Makefile diff --git a/tests/run-make/extern-fn-mangle/Makefile b/tests/run-make/extern-fn-mangle/Makefile deleted file mode 100644 index 3cbbf3839969f..0000000000000 --- a/tests/run-make/extern-fn-mangle/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/tests/run-make/extern-fn-mangle/rmake.rs b/tests/run-make/extern-fn-mangle/rmake.rs new file mode 100644 index 0000000000000..3db8b2a0db0eb --- /dev/null +++ b/tests/run-make/extern-fn-mangle/rmake.rs @@ -0,0 +1,16 @@ +// In this test, the functions foo() and bar() must avoid being mangled, as +// the external C function depends on them to return the correct sum of 3 + 5 = 8. +// This test therefore checks that the compiled and executed program respects the +// #[no_mangle] flags successfully. +// See https://github.com/rust-lang/rust/pull/15831 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("test"); + rustc().input("test.rs").run(); + run("test"); +}