Skip to content

Commit 66e5852

Browse files
committed
Auto merge of rust-lang#128112 - Oneirical:testidigitation-cantrip, r=jieyouxu
Migrate `share-generics-dylib`, `raw-dylib-import-name-type`, `raw-dylib-link-ordinal` and `raw-dylib-stdcall-ordinal` `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-msvc // already successful try-job: aarch64-apple try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc try-job: x86_64-gnu-llvm-18
2 parents 4db3d12 + 23cccb3 commit 66e5852

File tree

9 files changed

+142
-79
lines changed

9 files changed

+142
-79
lines changed

Diff for: src/tools/tidy/src/allowed_run_make_makefiles.txt

-4
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@ run-make/print-calling-conventions/Makefile
4141
run-make/print-target-list/Makefile
4242
run-make/raw-dylib-alt-calling-convention/Makefile
4343
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
4744
run-make/redundant-libs/Makefile
4845
run-make/remap-path-prefix-dwarf/Makefile
4946
run-make/reproducible-build-2/Makefile
5047
run-make/reproducible-build/Makefile
5148
run-make/rlib-format-packed-bundled-libs-2/Makefile
5249
run-make/rlib-format-packed-bundled-libs/Makefile
53-
run-make/share-generics-dylib/Makefile
5450
run-make/simd-ffi/Makefile
5551
run-make/split-debuginfo/Makefile
5652
run-make/stable-symbol-names/Makefile

Diff for: tests/run-make/raw-dylib-import-name-type/Makefile

-17
This file was deleted.

Diff for: tests/run-make/raw-dylib-import-name-type/rmake.rs

+37
Original file line numberDiff line numberDiff 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+
}

Diff for: tests/run-make/raw-dylib-link-ordinal/Makefile

-17
This file was deleted.

Diff for: tests/run-make/raw-dylib-link-ordinal/rmake.rs

+34
Original file line numberDiff line numberDiff 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+
}

Diff for: tests/run-make/raw-dylib-stdcall-ordinal/Makefile

-18
This file was deleted.

Diff for: tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs

+41
Original file line numberDiff line numberDiff 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+
}

Diff for: tests/run-make/share-generics-dylib/Makefile

-23
This file was deleted.

Diff for: tests/run-make/share-generics-dylib/rmake.rs

+30
Original file line numberDiff line numberDiff 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<i32>::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+
}

0 commit comments

Comments
 (0)