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 8f0e074

Browse files
committedJul 10, 2024
Auto merge of #127390 - Oneirical:rough-testimation, r=<try>
Migrate `raw-dylib-inline-cross-dylib` and `raw-dylib-custom-dlltool` `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). Please try: try-job: i686-mingw
2 parents c092b28 + 8e0871a commit 8f0e074

File tree

5 files changed

+86
-43
lines changed

5 files changed

+86
-43
lines changed
 

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

-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ run-make/print-target-list/Makefile
105105
run-make/prune-link-args/Makefile
106106
run-make/raw-dylib-alt-calling-convention/Makefile
107107
run-make/raw-dylib-c/Makefile
108-
run-make/raw-dylib-custom-dlltool/Makefile
109108
run-make/raw-dylib-import-name-type/Makefile
110-
run-make/raw-dylib-inline-cross-dylib/Makefile
111109
run-make/raw-dylib-link-ordinal/Makefile
112110
run-make/raw-dylib-stdcall-ordinal/Makefile
113111
run-make/redundant-libs/Makefile

‎tests/run-make/raw-dylib-custom-dlltool/Makefile

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Instead of using the default dlltool, the rust compiler can also accept a custom
2+
// command file with the -C dlltool flag. This test uses it to compile some rust code
3+
// with the raw_dylib Windows-exclusive feature, and checks that the output contains
4+
// the string passed from the custom dlltool, confirming that the default dlltool was
5+
// successfully overridden.
6+
// See https://github.com/rust-lang/rust/pull/109677
7+
8+
//@ only-windows
9+
//@ only-gnu
10+
//@ needs-dlltool
11+
// Reason: this test specifically checks the custom dlltool feature, only
12+
// available on Windows-gnu.
13+
14+
use run_make_support::{diff, rustc};
15+
16+
fn main() {
17+
let out = rustc()
18+
.crate_type("lib")
19+
.crate_name("raw_dylib_test")
20+
.input("lib.rs")
21+
.arg("-Cdlltool=script.cmd")
22+
.run()
23+
.stdout_utf8();
24+
diff().expected_file("output.txt").actual_text("actual_text", out).normalize(r#"\r"#, "").run();
25+
}

‎tests/run-make/raw-dylib-inline-cross-dylib/Makefile

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// When we generate the import library for a dylib or bin crate, we should generate it
2+
// for the symbols both for the current crate and all upstream crates. This allows for
3+
// using the link kind `raw-dylib` inside inline functions successfully. This test checks
4+
// that the import symbols in the object files match this convention, and that execution
5+
// of the binary results in all function names exported successfully.
6+
// See https://github.com/rust-lang/rust/pull/102988
7+
8+
//@ only-windows
9+
10+
use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc};
11+
12+
fn main() {
13+
rustc()
14+
.crate_type("dylib")
15+
.crate_name("raw_dylib_test")
16+
.input("lib.rs")
17+
.arg("-Cprefer-dynamic")
18+
.run();
19+
rustc()
20+
.crate_type("dylib")
21+
.crate_name("raw_dylib_test_wrapper")
22+
.input("lib_wrapper.rs")
23+
.arg("-Cprefer-dynamic")
24+
.run();
25+
rustc().crate_type("bin").input("driver.rs").arg("-Cprefer-dynamic").run();
26+
llvm_objdump()
27+
.arg("--private-headers")
28+
.input("driver.exe")
29+
.run()
30+
// Make sure we don't find an import to the functions we expect to be inlined.
31+
.assert_stdout_not_contains("inline_library_function")
32+
// Make sure we do find an import to the functions we expect to be imported.
33+
.assert_stdout_contains("library_function");
34+
if is_msvc() {
35+
cc().arg("-c").out_exe("extern_1").input("extern_1.c").run();
36+
cc().arg("-c").out_exe("extern_2").input("extern_2.c").run();
37+
cc().input("extern_1.obj")
38+
.arg("-link")
39+
.arg("-dll")
40+
.arg("-out:extern_1.dll")
41+
.arg("-noimplib")
42+
.run();
43+
cc().input("extern_2.obj")
44+
.arg("-link")
45+
.arg("-dll")
46+
.arg("-out:extern_2.dll")
47+
.arg("-noimplib")
48+
.run();
49+
} else {
50+
cc().arg("-v").arg("-c").out_exe("extern_1").input("extern_1.c").run();
51+
cc().arg("-v").arg("-c").out_exe("extern_2").input("extern_2.c").run();
52+
cc().input("extern_1").out_exe("extern_1.dll").arg("-shared").run();
53+
cc().input("extern_2").out_exe("extern_2.dll").arg("-shared").run();
54+
}
55+
let out = run("driver").stdout_utf8();
56+
diff()
57+
.expected_file("output.txt")
58+
.actual_text("actual_output", out)
59+
.normalize(r#"\r"#, "")
60+
.run();
61+
}

0 commit comments

Comments
 (0)
Failed to load comments.