rewrite raw-dylib-import-name-type to rmake

This commit is contained in:
Oneirical 2024-07-23 15:41:53 -04:00
parent 0c8f194737
commit 8c09a7f11e
3 changed files with 36 additions and 18 deletions

View File

@ -41,7 +41,6 @@ run-make/print-calling-conventions/Makefile
run-make/print-target-list/Makefile
run-make/raw-dylib-alt-calling-convention/Makefile
run-make/raw-dylib-c/Makefile
run-make/raw-dylib-import-name-type/Makefile
run-make/raw-dylib-link-ordinal/Makefile
run-make/raw-dylib-stdcall-ordinal/Makefile
run-make/redundant-libs/Makefile

View File

@ -1,17 +0,0 @@
# Test the behavior of #[link(.., kind = "raw-dylib")] with alternative calling conventions.
# only-x86
# only-windows
include ../tools.mk
all:
$(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"
$(call COMPILE_OBJ,"$(TMPDIR)"/extern.obj,extern.c)
ifdef IS_MSVC
$(CC) "$(TMPDIR)"/extern.obj extern.msvc.def -link -dll -out:"$(TMPDIR)"/extern.dll -noimplib
else
$(CC) "$(TMPDIR)"/extern.obj extern.gnu.def --no-leading-underscore -shared -o "$(TMPDIR)"/extern.dll
endif
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
$(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt

View File

@ -0,0 +1,36 @@
// `raw-dylib` is a Windows-specific attribute which emits idata sections for the items in the
// attached extern block,
// so they may be linked against without linking against an import library.
// To learn more, read https://github.com/rust-lang/rfcs/blob/master/text/2627-raw-dylib-kind.md
// This test uses this feature alongside `import_name_type`, which allows for customization
// of how Windows symbols will be named. The correctness of this feature is checked by comparison
// with expected output.
// See https://github.com/rust-lang/rust/pull/100732
//@ only-x86
//@ only-windows
use run_make_support::{cc, diff, is_msvc, run, rustc};
// NOTE: build_native_dynamic lib is not used, as the special `def` files
// must be passed to the CC compiler.
fn main() {
rustc().crate_type("bin").input("driver.rs").run();
if is_msvc() {
cc().arg("-c").out_exe("extern").input("extern.c").run();
cc().input("extern.obj")
.arg("extern.msvc.def")
.args(&["-link", "-dll", "-noimplib", "-out:extern.dll"])
.run();
} else {
cc().arg("-v").arg("-c").out_exe("extern.obj").input("extern.c").run();
cc().input("extern.obj")
.arg("extern.gnu.def")
.args(&["--no-leading-underscore", "-shared"])
.output("extern.dll")
.run();
};
let out = run("driver").stdout_utf8();
diff().expected_file("output.txt").actual_text("actual", out).run();
}