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#127390 - Oneirical:rough-testimation, r=<try>
Migrate `raw-dylib-inline-cross-dylib` and `raw-dylib-custom-dlltool` `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). Please try: try-job: i686-mingw
- Loading branch information
Showing
6 changed files
with
86 additions
and
44 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,24 @@ | ||
// Instead of using the default dlltool, the rust compiler can also accept a custom | ||
// command file with the -C dlltool flag. This test uses it to compile some rust code | ||
// with the raw_dylib Windows-exclusive feature, and checks that the output contains | ||
// the string passed from the custom dlltool, confirming that the default dlltool was | ||
// successfully overridden. | ||
// See https://github.com/rust-lang/rust/pull/109677 | ||
|
||
//@ only-windows | ||
//@ only-gnu | ||
//@ needs-dlltool | ||
// Reason: this test specifically checks the custom dlltool feature, only | ||
// available on Windows-gnu. | ||
|
||
use run_make_support::{diff, rustc}; | ||
|
||
fn main() { | ||
let out = rustc() | ||
.crate_type("lib") | ||
.crate_name("raw_dylib_test") | ||
.input("lib.rs") | ||
.arg("-Cdlltool=script.cmd") | ||
.run(); | ||
diff().expected_file("output.txt").actual_file("actual.txt").normalize(r#"\r"#, "").run(); | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
echo Called dlltool via script.cmd> %TMPDIR%\output.txt | ||
echo Called dlltool via script.cmd> %TMPDIR%\actual.txt | ||
dlltool.exe %* |
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,61 @@ | ||
// When we generate the import library for a dylib or bin crate, we should generate it | ||
// for the symbols both for the current crate and all upstream crates. This allows for | ||
// using the link kind `raw-dylib` inside inline functions successfully. This test checks | ||
// that the import symbols in the object files match this convention, and that execution | ||
// of the binary results in all function names exported successfully. | ||
// See https://github.com/rust-lang/rust/pull/102988 | ||
|
||
//@ only-windows | ||
|
||
use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc}; | ||
|
||
fn main() { | ||
rustc() | ||
.crate_type("dylib") | ||
.crate_name("raw_dylib_test") | ||
.input("lib.rs") | ||
.arg("-Cprefer-dynamic") | ||
.run(); | ||
rustc() | ||
.crate_type("dylib") | ||
.crate_name("raw_dylib_test_wrapper") | ||
.input("lib_wrapper.rs") | ||
.arg("-Cprefer-dynamic") | ||
.run(); | ||
rustc().crate_type("bin").input("driver.rs").arg("-Cprefer-dynamic").run(); | ||
llvm_objdump() | ||
.arg("--private-headers") | ||
.input("driver.exe") | ||
.run() | ||
// Make sure we don't find an import to the functions we expect to be inlined. | ||
.assert_stdout_not_contains("inline_library_function") | ||
// Make sure we do find an import to the functions we expect to be imported. | ||
.assert_stdout_contains("library_function"); | ||
if is_msvc() { | ||
cc().arg("-c").out_exe("extern_1").input("extern_1.c").run(); | ||
cc().arg("-c").out_exe("extern_2").input("extern_2.c").run(); | ||
cc().input("extern_1.obj") | ||
.arg("-link") | ||
.arg("-dll") | ||
.arg("-out:extern_1.dll") | ||
.arg("-noimplib") | ||
.run(); | ||
cc().input("extern_2.obj") | ||
.arg("-link") | ||
.arg("-dll") | ||
.arg("-out:extern_2.dll") | ||
.arg("-noimplib") | ||
.run(); | ||
} else { | ||
cc().arg("-v").arg("-c").out_exe("extern_1").input("extern_1.c").run(); | ||
cc().arg("-v").arg("-c").out_exe("extern_2").input("extern_2.c").run(); | ||
cc().input("extern_1").out_exe("extern_1.dll").arg("-shared").run(); | ||
cc().input("extern_2").out_exe("extern_2.dll").arg("-shared").run(); | ||
} | ||
let out = run("driver").stdout_utf8(); | ||
diff() | ||
.expected_file("output.txt") | ||
.actual_text("actual_output", out) | ||
.normalize(r#"\r"#, "") | ||
.run(); | ||
} |