Skip to content

Commit 5069856

Browse files
committed
Auto merge of #127663 - Oneirical:fuzzy-testure, r=jieyouxu
Migrate 9 more very similar FFI `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). For the tracking issue: - return-non-c-like-enum-from-c - pass-non-c-like-enum-to-c - c-static-dylib - c-static-rlib - extern-fn-generic - extern-fn-with-union - lto-no-link-whole-rlib - linkage-attr-on-static - issue-28595
2 parents 2e6fc42 + fdc8d62 commit 5069856

File tree

23 files changed

+154
-82
lines changed

23 files changed

+154
-82
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
run-make/branch-protection-check-IBT/Makefile
22
run-make/c-dynamic-dylib/Makefile
33
run-make/c-dynamic-rlib/Makefile
4-
run-make/c-static-dylib/Makefile
5-
run-make/c-static-rlib/Makefile
64
run-make/c-unwind-abi-catch-lib-panic/Makefile
75
run-make/c-unwind-abi-catch-panic/Makefile
86
run-make/cat-and-grep-sanity-check/Makefile
@@ -21,9 +19,7 @@ run-make/emit-to-stdout/Makefile
2119
run-make/export-executable-symbols/Makefile
2220
run-make/extern-diff-internal-name/Makefile
2321
run-make/extern-flag-disambiguates/Makefile
24-
run-make/extern-fn-generic/Makefile
2522
run-make/extern-fn-reachable/Makefile
26-
run-make/extern-fn-with-union/Makefile
2723
run-make/extern-multiple-copies/Makefile
2824
run-make/extern-multiple-copies2/Makefile
2925
run-make/fmt-write-bloat/Makefile
@@ -36,7 +32,6 @@ run-make/interdependent-c-libraries/Makefile
3632
run-make/issue-107094/Makefile
3733
run-make/issue-14698/Makefile
3834
run-make/issue-15460/Makefile
39-
run-make/issue-28595/Makefile
4035
run-make/issue-33329/Makefile
4136
run-make/issue-35164/Makefile
4237
run-make/issue-36710/Makefile
@@ -52,11 +47,9 @@ run-make/libtest-junit/Makefile
5247
run-make/libtest-thread-limit/Makefile
5348
run-make/link-cfg/Makefile
5449
run-make/link-framework/Makefile
55-
run-make/linkage-attr-on-static/Makefile
5650
run-make/long-linker-command-lines-cmd-exe/Makefile
5751
run-make/long-linker-command-lines/Makefile
5852
run-make/lto-linkage-used-attr/Makefile
59-
run-make/lto-no-link-whole-rlib/Makefile
6053
run-make/macos-deployment-target/Makefile
6154
run-make/min-global-align/Makefile
6255
run-make/native-link-modifier-bundle/Makefile
@@ -65,7 +58,6 @@ run-make/no-alloc-shim/Makefile
6558
run-make/no-builtins-attribute/Makefile
6659
run-make/no-duplicate-libs/Makefile
6760
run-make/panic-abort-eh_frame/Makefile
68-
run-make/pass-non-c-like-enum-to-c/Makefile
6961
run-make/pdb-buildinfo-cl-cmd/Makefile
7062
run-make/pgo-gen-lto/Makefile
7163
run-make/pgo-gen-no-imp-symbols/Makefile
@@ -82,7 +74,6 @@ run-make/redundant-libs/Makefile
8274
run-make/remap-path-prefix-dwarf/Makefile
8375
run-make/reproducible-build-2/Makefile
8476
run-make/reproducible-build/Makefile
85-
run-make/return-non-c-like-enum-from-c/Makefile
8677
run-make/rlib-format-packed-bundled-libs-2/Makefile
8778
run-make/rlib-format-packed-bundled-libs-3/Makefile
8879
run-make/rlib-format-packed-bundled-libs/Makefile

tests/run-make/c-static-dylib/Makefile

-13
This file was deleted.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This test checks that static Rust linking with C does not encounter any errors,
2+
// with dynamic dependencies given preference over static.
3+
// See https://github.com/rust-lang/rust/issues/10434
4+
5+
//@ ignore-cross-compile
6+
// Reason: the compiled binary is executed
7+
8+
use run_make_support::{
9+
build_native_static_lib, dynamic_lib_name, rfs, run, run_fail, rustc, static_lib_name,
10+
};
11+
12+
fn main() {
13+
build_native_static_lib("cfoo");
14+
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
15+
rustc().input("bar.rs").run();
16+
rfs::remove_file(static_lib_name("cfoo"));
17+
run("bar");
18+
rfs::remove_file(dynamic_lib_name("foo"));
19+
run_fail("bar");
20+
}

tests/run-make/c-static-rlib/Makefile

-12
This file was deleted.

tests/run-make/c-static-rlib/rmake.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This test checks that static Rust linking with C does not encounter any errors,
2+
// with static dependencies given preference over dynamic. (This is the default behaviour.)
3+
// See https://github.com/rust-lang/rust/issues/10434
4+
5+
//@ ignore-cross-compile
6+
// Reason: the compiled binary is executed
7+
8+
use run_make_support::{build_native_static_lib, rfs, run, rust_lib_name, rustc, static_lib_name};
9+
10+
fn main() {
11+
build_native_static_lib("cfoo");
12+
rustc().input("foo.rs").run();
13+
rustc().input("bar.rs").run();
14+
rfs::remove_file(rust_lib_name("foo"));
15+
rfs::remove_file(static_lib_name("cfoo"));
16+
run("bar");
17+
}

tests/run-make/extern-fn-generic/Makefile

-7
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Generic types in foreign-function interfaces were introduced in #15831 - this
2+
// test simply runs a Rust program containing generics that is also reliant on
3+
// a C library, and checks that compilation and execution are successful.
4+
// See https://github.com/rust-lang/rust/pull/15831
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("test");
13+
rustc().input("testcrate.rs").run();
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}

tests/run-make/extern-fn-with-union/Makefile

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// If an external function from foreign-function interface was called upon,
2+
// its attributes would only be passed to LLVM if and only if it was called in the same crate.
3+
// This caused passing around unions to be incorrect.
4+
// See https://github.com/rust-lang/rust/pull/14191
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("ctest");
13+
rustc().input("testcrate.rs").run();
14+
rustc().input("test.rs").run();
15+
run("test");
16+
}

tests/run-make/issue-28595/Makefile

-7
This file was deleted.

tests/run-make/linkage-attr-on-static/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// #[linkage] is a useful attribute which can be applied to statics to allow
2+
// external linkage, something which was not possible before #18890. This test
3+
// checks that using this new feature results in successful compilation and execution.
4+
// See https://github.com/rust-lang/rust/pull/18890
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("foo");
13+
rustc().input("bar.rs").run();
14+
run("bar");
15+
}

tests/run-make/lto-no-link-whole-rlib/Makefile

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// In order to improve linking performance, entire rlibs will only be linked if a dylib is being
2+
// created. Otherwise, an executable will only link one rlib as usual. Linking will fail in this
3+
// test should this optimization be reverted.
4+
// See https://github.com/rust-lang/rust/pull/31460
5+
6+
//@ ignore-cross-compile
7+
// Reason: the compiled binary is executed
8+
9+
use run_make_support::{build_native_static_lib, run, rustc};
10+
11+
fn main() {
12+
build_native_static_lib("foo");
13+
build_native_static_lib("bar");
14+
rustc().input("lib1.rs").run();
15+
rustc().input("lib2.rs").run();
16+
rustc().input("main.rs").arg("-Clto").run();
17+
run("main");
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// An old compiler bug from 2015 caused native libraries to be loaded in the
2+
// wrong order, causing `b` to be loaded before `a` in this test. If the compilation
3+
// is successful, the libraries were loaded in the correct order.
4+
5+
//@ ignore-cross-compile
6+
// Reason: the compiled binary is executed
7+
8+
use run_make_support::{build_native_static_lib, run, rustc};
9+
10+
fn main() {
11+
build_native_static_lib("a");
12+
build_native_static_lib("b");
13+
rustc().input("a.rs").run();
14+
rustc().input("b.rs").run();
15+
run("b");
16+
}

tests/run-make/pass-non-c-like-enum-to-c/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Similar to the `return-non-c-like-enum-from-c` test, where
2+
// the C code is the library, and the Rust code compiles
3+
// into the executable. Once again, enum variants should be treated
4+
// like an union of structs, which should prevent segfaults or
5+
// unexpected results. The only difference with the aforementioned
6+
// test is that the structs are passed into C directly through the
7+
// `tt_add` and `t_add` function calls.
8+
// See https://github.com/rust-lang/rust/issues/68190
9+
10+
//@ ignore-cross-compile
11+
// Reason: the compiled binary is executed
12+
13+
use run_make_support::{build_native_static_lib, run, rustc};
14+
15+
fn main() {
16+
build_native_static_lib("test");
17+
rustc().input("nonclike.rs").arg("-ltest").run();
18+
run("nonclike");
19+
}

tests/run-make/return-non-c-like-enum-from-c/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// A reversed version of the `return-non-c-like-enum` test, though
2+
// this time, the C code is the library, and the Rust code compiles
3+
// into the executable. Once again, enum variants should be treated
4+
// like an union of structs, which should prevent segfaults or
5+
// unexpected results.
6+
// See https://github.com/rust-lang/rust/issues/68190
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("nonclike.rs").arg("-ltest").run();
16+
run("nonclike");
17+
}

0 commit comments

Comments
 (0)