forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#127663 - Oneirical:fuzzy-testure, r=jieyouxu
Migrate 9 more 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). 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
- Loading branch information
Showing
23 changed files
with
154 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This test checks that static Rust linking with C does not encounter any errors, | ||
// with dynamic dependencies given preference over static. | ||
// See https://github.com/rust-lang/rust/issues/10434 | ||
|
||
//@ ignore-cross-compile | ||
// Reason: the compiled binary is executed | ||
|
||
use run_make_support::{ | ||
build_native_static_lib, dynamic_lib_name, rfs, run, run_fail, rustc, static_lib_name, | ||
}; | ||
|
||
fn main() { | ||
build_native_static_lib("cfoo"); | ||
rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); | ||
rustc().input("bar.rs").run(); | ||
rfs::remove_file(static_lib_name("cfoo")); | ||
run("bar"); | ||
rfs::remove_file(dynamic_lib_name("foo")); | ||
run_fail("bar"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This test checks that static Rust linking with C does not encounter any errors, | ||
// with static dependencies given preference over dynamic. (This is the default behaviour.) | ||
// See https://github.com/rust-lang/rust/issues/10434 | ||
|
||
//@ ignore-cross-compile | ||
// Reason: the compiled binary is executed | ||
|
||
use run_make_support::{build_native_static_lib, rfs, run, rust_lib_name, rustc, static_lib_name}; | ||
|
||
fn main() { | ||
build_native_static_lib("cfoo"); | ||
rustc().input("foo.rs").run(); | ||
rustc().input("bar.rs").run(); | ||
rfs::remove_file(rust_lib_name("foo")); | ||
rfs::remove_file(static_lib_name("cfoo")); | ||
run("bar"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Generic types in foreign-function interfaces were introduced in #15831 - this | ||
// test simply runs a Rust program containing generics that is also reliant on | ||
// a C library, and checks that compilation and execution are successful. | ||
// 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("testcrate.rs").run(); | ||
rustc().input("test.rs").run(); | ||
run("test"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// If an external function from foreign-function interface was called upon, | ||
// its attributes would only be passed to LLVM if and only if it was called in the same crate. | ||
// This caused passing around unions to be incorrect. | ||
// See https://github.com/rust-lang/rust/pull/14191 | ||
|
||
//@ 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("testcrate.rs").run(); | ||
rustc().input("test.rs").run(); | ||
run("test"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// #[linkage] is a useful attribute which can be applied to statics to allow | ||
// external linkage, something which was not possible before #18890. This test | ||
// checks that using this new feature results in successful compilation and execution. | ||
// See https://github.com/rust-lang/rust/pull/18890 | ||
|
||
//@ 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("bar.rs").run(); | ||
run("bar"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// In order to improve linking performance, entire rlibs will only be linked if a dylib is being | ||
// created. Otherwise, an executable will only link one rlib as usual. Linking will fail in this | ||
// test should this optimization be reverted. | ||
// See https://github.com/rust-lang/rust/pull/31460 | ||
|
||
//@ 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"); | ||
build_native_static_lib("bar"); | ||
rustc().input("lib1.rs").run(); | ||
rustc().input("lib2.rs").run(); | ||
rustc().input("main.rs").arg("-Clto").run(); | ||
run("main"); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// An old compiler bug from 2015 caused native libraries to be loaded in the | ||
// wrong order, causing `b` to be loaded before `a` in this test. If the compilation | ||
// is successful, the libraries were loaded in the correct order. | ||
|
||
//@ 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("a"); | ||
build_native_static_lib("b"); | ||
rustc().input("a.rs").run(); | ||
rustc().input("b.rs").run(); | ||
run("b"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Similar to the `return-non-c-like-enum-from-c` test, where | ||
// the C code is the library, and the Rust code compiles | ||
// into the executable. Once again, enum variants should be treated | ||
// like an union of structs, which should prevent segfaults or | ||
// unexpected results. The only difference with the aforementioned | ||
// test is that the structs are passed into C directly through the | ||
// `tt_add` and `t_add` function calls. | ||
// See https://github.com/rust-lang/rust/issues/68190 | ||
|
||
//@ 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("nonclike.rs").arg("-ltest").run(); | ||
run("nonclike"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// A reversed version of the `return-non-c-like-enum` test, though | ||
// this time, the C code is the library, and the Rust code compiles | ||
// into the executable. Once again, enum variants should be treated | ||
// like an union of structs, which should prevent segfaults or | ||
// unexpected results. | ||
// See https://github.com/rust-lang/rust/issues/68190 | ||
|
||
//@ 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("nonclike.rs").arg("-ltest").run(); | ||
run("nonclike"); | ||
} |