about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/raw-dylib-import-name-type/Makefile17
-rw-r--r--tests/run-make/raw-dylib-import-name-type/rmake.rs36
3 files changed, 36 insertions, 18 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 3f416448f6d..fb72662405c 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -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
diff --git a/tests/run-make/raw-dylib-import-name-type/Makefile b/tests/run-make/raw-dylib-import-name-type/Makefile
deleted file mode 100644
index 901d3e861c2..00000000000
--- a/tests/run-make/raw-dylib-import-name-type/Makefile
+++ /dev/null
@@ -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
diff --git a/tests/run-make/raw-dylib-import-name-type/rmake.rs b/tests/run-make/raw-dylib-import-name-type/rmake.rs
new file mode 100644
index 00000000000..4dc916610e0
--- /dev/null
+++ b/tests/run-make/raw-dylib-import-name-type/rmake.rs
@@ -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();
+}