Auto merge of #128112 - Oneirical:testidigitation-cantrip, r=jieyouxu · rust-lang/rust@66e5852 (original) (raw)

File tree

9 files changed

lines changed

9 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -41,16 +41,12 @@ run-make/print-calling-conventions/Makefile
41 41 run-make/print-target-list/Makefile
42 42 run-make/raw-dylib-alt-calling-convention/Makefile
43 43 run-make/raw-dylib-c/Makefile
44 -run-make/raw-dylib-import-name-type/Makefile
45 -run-make/raw-dylib-link-ordinal/Makefile
46 -run-make/raw-dylib-stdcall-ordinal/Makefile
47 44 run-make/redundant-libs/Makefile
48 45 run-make/remap-path-prefix-dwarf/Makefile
49 46 run-make/reproducible-build-2/Makefile
50 47 run-make/reproducible-build/Makefile
51 48 run-make/rlib-format-packed-bundled-libs-2/Makefile
52 49 run-make/rlib-format-packed-bundled-libs/Makefile
53 -run-make/share-generics-dylib/Makefile
54 50 run-make/simd-ffi/Makefile
55 51 run-make/split-debuginfo/Makefile
56 52 run-make/stable-symbol-names/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1 +// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
2 +// attached extern block,
3 +// so they may be linked against without linking against an import library.
4 +// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
5 +// This test uses this feature alongside `import_name_type`, which allows for customization
6 +// of how Windows symbols will be named. A sanity check of this feature is done by comparison
7 +// with expected output.
8 +// See https://github.com/rust-lang/rust/pull/100732
9 +
10 +//@ only-x86
11 +//@ only-windows
12 +// Reason: this test specifically exercises a 32bit Windows calling convention.
13 +
14 +use run_make_support::{cc, diff, is_msvc, run, rustc};
15 +
16 +// NOTE: build_native_dynamic lib is not used, as the special `def` files
17 +// must be passed to the CC compiler.
18 +
19 +fn main() {
20 +rustc().crate_type("bin").input("driver.rs").run();
21 +if is_msvc() {
22 +cc().arg("-c").out_exe("extern").input("extern.c").run();
23 +cc().input("extern.obj")
24 +.arg("extern.msvc.def")
25 +.args(&["-link", "-dll", "-noimplib", "-out:extern.dll"])
26 +.run();
27 +} else {
28 +cc().arg("-v").arg("-c").out_exe("extern.obj").input("extern.c").run();
29 +cc().input("extern.obj")
30 +.arg("extern.gnu.def")
31 +.args(&["--no-leading-underscore", "-shared"])
32 +.output("extern.dll")
33 +.run();
34 +};
35 +let out = run("driver").stdout_utf8();
36 +diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
37 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
1 +// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
2 +// attached extern block,
3 +// so they may be linked against without linking against an import library.
4 +// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
5 +// `#[link_ordinal(n)]` allows Rust to link against DLLs that export symbols by ordinal rather
6 +// than by name. As long as the ordinal matches, the name of the function in Rust is not
7 +// required to match the name of the corresponding function in the exporting DLL.
8 +// This test is a sanity check for this feature, done by comparing its output against expected
9 +// output.
10 +// See https://github.com/rust-lang/rust/pull/89025
11 +
12 +//@ only-windows
13 +
14 +use run_make_support::{cc, diff, is_msvc, run, rustc};
15 +
16 +// NOTE: build_native_dynamic lib is not used, as the special `def` files
17 +// must be passed to the CC compiler.
18 +
19 +fn main() {
20 +rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
21 +rustc().crate_type("bin").input("driver.rs").run();
22 +if is_msvc() {
23 +cc().arg("-c").out_exe("exporter").input("exporter.c").run();
24 +cc().input("exporter.obj")
25 +.arg("exporter.def")
26 +.args(&["-link", "-dll", "-noimplib", "-out:exporter.dll"])
27 +.run();
28 +} else {
29 +cc().arg("-v").arg("-c").out_exe("exporter.obj").input("exporter.c").run();
30 +cc().input("exporter.obj").arg("exporter.def").arg("-shared").output("exporter.dll").run();
31 +};
32 +let out = run("driver").stdout_utf8();
33 +diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
34 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
1 +// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
2 +// attached extern block,
3 +// so they may be linked against without linking against an import library.
4 +// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
5 +// Almost identical to `raw-dylib-link-ordinal`, but with the addition of calling conventions,
6 +// such as stdcall.
7 +// See https://github.com/rust-lang/rust/pull/90782
8 +
9 +//@ only-x86
10 +//@ only-windows
11 +// Reason: this test specifically exercises a 32bit Windows calling convention.
12 +
13 +use run_make_support::{cc, diff, is_msvc, run, rustc};
14 +
15 +// NOTE: build_native_dynamic lib is not used, as the special `def` files
16 +// must be passed to the CC compiler.
17 +
18 +fn main() {
19 +rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run();
20 +rustc().crate_type("bin").input("driver.rs").run();
21 +if is_msvc() {
22 +cc().arg("-c").out_exe("exporter").input("exporter.c").run();
23 +cc().input("exporter.obj")
24 +.arg("exporter-msvc.def")
25 +.args(&["-link", "-dll", "-noimplib", "-out:exporter.dll"])
26 +.run();
27 +} else {
28 +cc().arg("-v").arg("-c").out_exe("exporter.obj").input("exporter.c").run();
29 +cc().input("exporter.obj")
30 +.arg("exporter-gnu.def")
31 +.arg("-shared")
32 +.output("exporter.dll")
33 +.run();
34 +};
35 +let out = run("driver").stdout_utf8();
36 +diff()
37 +.expected_file("expected_output.txt")
38 +.actual_text("actual", out)
39 +.normalize(r#"\r"#, "")
40 +.run();
41 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1 +// This test makes sure all generic instances get re-exported from Rust dylibs for use by
2 +// `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
3 +// which both provide an instance of `Cell::set`. There is `instance_user_dylib` which is
4 +// supposed to re-export both these instances, and then there are `instance_user_a_rlib` and
5 +// `instance_user_b_rlib` which each rely on a specific instance to be available.
6 +//
7 +// In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does
8 +// not export both then we'll get an `undefined reference` error for one of the instances.
9 +//
10 +// This is regression test for https://github.com/rust-lang/rust/issues/67276.
11 +
12 +use run_make_support::rustc;
13 +
14 +fn main() {
15 +compile("rlib", "instance_provider_a.rs");
16 +compile("rlib", "instance_provider_b.rs");
17 +compile("dylib", "instance_user_dylib.rs");
18 +compile("rlib", "instance_user_a_rlib.rs");
19 +compile("rlib", "instance_user_b_rlib.rs");
20 +compile("bin", "linked_leaf.rs");
21 +}
22 +
23 +fn compile(crate_type: &str, input: &str) {
24 +rustc()
25 +.input(input)
26 +.crate_type(crate_type)
27 +.args(&["-Cprefer-dynamic", "-Zshare-generics=yes", "-Csymbol-mangling-version=v0"])
28 +.codegen_units(1)
29 +.run();
30 +}