Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5672b4a

Browse files
authoredJul 18, 2024
Unrolled build for rust-lang#127491
Rollup merge of rust-lang#127491 - Oneirical:bulletproof-test, r=jieyouxu Migrate 8 very similar FFI `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). There are some more of these, but while the code is almost always the same, I want to keep the number reasonable so my doc comments can be inspected for potential inaccuracies. Tell me if 8 is too much, I can cut this down. For the tracking issue: - issue-25581 - extern-fn-with-extern-types - extern-fn-struct-passing-abi - longjmp-across-rust - static-extern-type - extern-fn-explicit-align - extern-fn-with-packed-struct - extern-fn-mangle
2 parents 52f3c71 + c68d25b commit 5672b4a

File tree

19 files changed

+133
-56
lines changed

19 files changed

+133
-56
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-8
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ run-make/emit-to-stdout/Makefile
2323
run-make/export-executable-symbols/Makefile
2424
run-make/extern-diff-internal-name/Makefile
2525
run-make/extern-flag-disambiguates/Makefile
26-
run-make/extern-fn-explicit-align/Makefile
2726
run-make/extern-fn-generic/Makefile
28-
run-make/extern-fn-mangle/Makefile
2927
run-make/extern-fn-reachable/Makefile
30-
run-make/extern-fn-struct-passing-abi/Makefile
31-
run-make/extern-fn-with-extern-types/Makefile
32-
run-make/extern-fn-with-packed-struct/Makefile
3328
run-make/extern-fn-with-union/Makefile
3429
run-make/extern-multiple-copies/Makefile
3530
run-make/extern-multiple-copies2/Makefile
@@ -44,7 +39,6 @@ run-make/issue-107094/Makefile
4439
run-make/issue-14698/Makefile
4540
run-make/issue-15460/Makefile
4641
run-make/issue-22131/Makefile
47-
run-make/issue-25581/Makefile
4842
run-make/issue-26006/Makefile
4943
run-make/issue-28595/Makefile
5044
run-make/issue-33329/Makefile
@@ -67,7 +61,6 @@ run-make/link-path-order/Makefile
6761
run-make/linkage-attr-on-static/Makefile
6862
run-make/long-linker-command-lines-cmd-exe/Makefile
6963
run-make/long-linker-command-lines/Makefile
70-
run-make/longjmp-across-rust/Makefile
7164
run-make/lto-linkage-used-attr/Makefile
7265
run-make/lto-no-link-whole-rlib/Makefile
7366
run-make/lto-smoke-c/Makefile
@@ -111,7 +104,6 @@ run-make/simd-ffi/Makefile
111104
run-make/split-debuginfo/Makefile
112105
run-make/stable-symbol-names/Makefile
113106
run-make/static-dylib-by-default/Makefile
114-
run-make/static-extern-type/Makefile
115107
run-make/staticlib-blank-lib/Makefile
116108
run-make/staticlib-dylib-linkage/Makefile
117109
run-make/symbol-mangling-hashed/Makefile

‎tests/run-make/extern-fn-explicit-align/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// The compiler's rules of alignment for indirectly passed values in a 16-byte aligned argument,
2+
// in a C external function, used to be arbitrary. Unexpected behavior would occasionally occur
3+
// and cause memory corruption. This was fixed in #112157, streamlining the way alignment occurs,
4+
// and this test reproduces the case featured in the issue, checking that it compiles and executes
5+
// successfully.
6+
// See https://github.com/rust-lang/rust/issues/80127
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{build_native_static_lib, run, rustc};
12+
13+
fn main() {
14+
build_native_static_lib("test");
15+
rustc().input("test.rs").run();
16+
run("test");
17+
}

‎tests/run-make/extern-fn-mangle/Makefile

-6
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// In this test, the functions foo() and bar() must avoid being mangled, as
2+
// the external C function depends on them to return the correct sum of 3 + 5 = 8.
3+
// This test therefore checks that the compiled and executed program respects the
4+
// #[no_mangle] flags successfully.
5+
// See https://github.com/rust-lang/rust/pull/15831
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed
9+
10+
use run_make_support::{build_native_static_lib, run, rustc};
11+
12+
fn main() {
13+
build_native_static_lib("test");
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Slices were broken when implicated in foreign-function interface (FFI) with
2+
// a C library, with something as simple as measuring the length or returning
3+
// an item at a certain index of a slice would cause an internal compiler error (ICE).
4+
// This was fixed in #25653, and this test checks that slices in Rust-C FFI can be part
5+
// of a program that compiles and executes successfully.
6+
// See https://github.com/rust-lang/rust/issues/25581
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{build_native_static_lib, run, rustc};
12+
13+
fn main() {
14+
build_native_static_lib("test");
15+
rustc().input("test.rs").run();
16+
run("test");
17+
}
File renamed without changes.

‎tests/run-make/extern-fn-struct-passing-abi/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Functions with more than 6 arguments using foreign function interfaces (FFI) with C libraries
2+
// would have their arguments unexpectedly swapped, causing unexpected behaviour in Rust-C FFI
3+
// programs. This test compiles and executes Rust code with bulky functions of up to 7 arguments
4+
// and uses assertions to check for unexpected swaps.
5+
// See https://github.com/rust-lang/rust/issues/25594
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed
9+
10+
use run_make_support::{build_native_static_lib, run, rustc};
11+
12+
fn main() {
13+
build_native_static_lib("test");
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}

‎tests/run-make/extern-fn-with-extern-types/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This test checks the functionality of foreign function interface (FFI) where Rust
2+
// must call upon a C library defining functions, where these functions also use custom
3+
// types defined by the C file. In addition to compilation being successful, the binary
4+
// should also successfully execute.
5+
// See https://github.com/rust-lang/rust/pull/44295
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed
9+
10+
use run_make_support::{build_native_static_lib, run, rustc};
11+
12+
fn main() {
13+
build_native_static_lib("ctest");
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}

‎tests/run-make/extern-fn-with-packed-struct/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Packed structs, in C, occupy less bytes in memory, but are more
2+
// vulnerable to alignment errors. Passing them around in a Rust-C foreign
3+
// function interface (FFI) would cause unexpected behavior, until this was
4+
// fixed in #16584. This test checks that a Rust program with a C library
5+
// compiles and executes successfully, even with usage of a packed struct.
6+
// See https://github.com/rust-lang/rust/issues/16574
7+
8+
//@ ignore-cross-compile
9+
// Reason: the compiled binary is executed
10+
11+
use run_make_support::{build_native_static_lib, run, rustc};
12+
13+
fn main() {
14+
build_native_static_lib("test");
15+
rustc().input("test.rs").run();
16+
run("test");
17+
}

‎tests/run-make/issue-25581/Makefile

-6
This file was deleted.

‎tests/run-make/longjmp-across-rust/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// longjmp, an error handling function used in C, is useful
2+
// for jumping out of nested call chains... but it used to accidentally
3+
// trigger Rust's cleanup system in a way that caused an unexpected abortion
4+
// of the program. After this was fixed in #48572, this test compiles and executes
5+
// a program that jumps between Rust and its C library, with longjmp included. For
6+
// the test to succeed, no unexpected abortion should occur.
7+
// See https://github.com/rust-lang/rust/pull/48572
8+
9+
//@ ignore-cross-compile
10+
// Reason: the compiled binary is executed
11+
12+
use run_make_support::{build_native_static_lib, run, rustc};
13+
14+
fn main() {
15+
build_native_static_lib("foo");
16+
rustc().input("main.rs").run();
17+
run("main");
18+
}

‎tests/run-make/static-extern-type/Makefile

-6
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Static variables coming from a C library through foreign function interface (FFI) are unsized
2+
// at compile time - and assuming they are sized used to cause an internal compiler error (ICE).
3+
// After this was fixed in #58192, this test checks that external statics can be safely used in
4+
// a program that both compiles and executes successfully.
5+
// See https://github.com/rust-lang/rust/issues/57876
6+
7+
//@ ignore-cross-compile
8+
// Reason: the compiled binary is executed
9+
10+
use run_make_support::{build_native_static_lib, run, rustc};
11+
12+
fn main() {
13+
build_native_static_lib("define-foo");
14+
rustc().arg("-ldefine-foo").input("use-foo.rs").run();
15+
run("use-foo");
16+
}

0 commit comments

Comments
 (0)
Failed to load comments.