Skip to content

Commit 9ffe161

Browse files
committed
rewrite raw-dylib-link-ordinal to rmake
1 parent 8c09a7f commit 9ffe161

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ 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-link-ordinal/Makefile
4544
run-make/raw-dylib-stdcall-ordinal/Makefile
4645
run-make/redundant-libs/Makefile
4746
run-make/remap-path-prefix-dwarf/Makefile

tests/run-make/raw-dylib-link-ordinal/Makefile

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 checks the correctness of this feature 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.msvc.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")
31+
.arg("exporter.gnu.def")
32+
.args(&["--no-leading-underscore", "-shared"])
33+
.output("exporter.dll")
34+
.run();
35+
};
36+
let out = run("driver").stdout_utf8();
37+
diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
38+
}

0 commit comments

Comments
 (0)