Skip to content

Commit ae144bf

Browse files
committed
rewrite raw-dylib-inline-cross-dylib to rmake
1 parent 9a21ac8 commit ae144bf

File tree

3 files changed

+61
-31
lines changed

3 files changed

+61
-31
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ run-make/raw-dylib-alt-calling-convention/Makefile
121121
run-make/raw-dylib-c/Makefile
122122
run-make/raw-dylib-custom-dlltool/Makefile
123123
run-make/raw-dylib-import-name-type/Makefile
124-
run-make/raw-dylib-inline-cross-dylib/Makefile
125124
run-make/raw-dylib-link-ordinal/Makefile
126125
run-make/raw-dylib-stdcall-ordinal/Makefile
127126
run-make/redundant-libs/Makefile

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.obj").input("extern_1.c").run();
36+
cc().arg("-c").out_exe("extern_2.obj").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.obj").input("extern_1.c").run();
51+
cc().arg("-v").arg("-c").out_exe("extern_2.obj").input("extern_2.c").run();
52+
cc().input("extern_1.obj").out_exe("extern_1.dll").arg("-shared").run();
53+
cc().input("extern_2.obj").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)