summaryrefslogtreecommitdiffstats
path: root/src/test/run-make/raw-dylib-c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-make/raw-dylib-c')
-rw-r--r--src/test/run-make/raw-dylib-c/Makefile28
-rw-r--r--src/test/run-make/raw-dylib-c/driver.rs5
-rw-r--r--src/test/run-make/raw-dylib-c/extern_1.c16
-rw-r--r--src/test/run-make/raw-dylib-c/extern_2.c6
-rw-r--r--src/test/run-make/raw-dylib-c/lib.rs26
-rw-r--r--src/test/run-make/raw-dylib-c/output.txt3
6 files changed, 84 insertions, 0 deletions
diff --git a/src/test/run-make/raw-dylib-c/Makefile b/src/test/run-make/raw-dylib-c/Makefile
new file mode 100644
index 000000000..713f66507
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/Makefile
@@ -0,0 +1,28 @@
+# Test the behavior of #[link(.., kind = "raw-dylib")] on windows-msvc
+
+# only-windows
+
+-include ../../run-make-fulldeps/tools.mk
+
+all:
+ $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
+ $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"
+ $(RUSTC) --crate-type bin --crate-name raw_dylib_test_bin lib.rs
+ $(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c)
+ $(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c)
+ifdef IS_MSVC
+ $(CC) "$(TMPDIR)"/extern_1.obj -link -dll -out:"$(TMPDIR)"/extern_1.dll -noimplib
+ $(CC) "$(TMPDIR)"/extern_2.obj -link -dll -out:"$(TMPDIR)"/extern_2.dll -noimplib
+else
+ $(CC) "$(TMPDIR)"/extern_1.obj -shared -o "$(TMPDIR)"/extern_1.dll
+ $(CC) "$(TMPDIR)"/extern_2.obj -shared -o "$(TMPDIR)"/extern_2.dll
+endif
+ "$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
+ "$(TMPDIR)"/raw_dylib_test_bin > "$(TMPDIR)"/output_bin.txt
+
+ifdef RUSTC_BLESS_TEST
+ cp "$(TMPDIR)"/output.txt output.txt
+else
+ $(DIFF) output.txt "$(TMPDIR)"/output.txt
+ $(DIFF) output.txt "$(TMPDIR)"/output_bin.txt
+endif
diff --git a/src/test/run-make/raw-dylib-c/driver.rs b/src/test/run-make/raw-dylib-c/driver.rs
new file mode 100644
index 000000000..4059ede11
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/driver.rs
@@ -0,0 +1,5 @@
+extern crate raw_dylib_test;
+
+fn main() {
+ raw_dylib_test::library_function();
+}
diff --git a/src/test/run-make/raw-dylib-c/extern_1.c b/src/test/run-make/raw-dylib-c/extern_1.c
new file mode 100644
index 000000000..72737c086
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/extern_1.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+__declspec(dllexport) void extern_fn_1() {
+ printf("extern_fn_1\n");
+ fflush(stdout);
+}
+
+__declspec(dllexport) void extern_fn_2() {
+ printf("extern_fn_2; didn't get the rename\n");
+ fflush(stdout);
+}
+
+__declspec(dllexport) void extern_fn_with_long_name() {
+ printf("extern_fn_with_long_name; got the rename\n");
+ fflush(stdout);
+}
diff --git a/src/test/run-make/raw-dylib-c/extern_2.c b/src/test/run-make/raw-dylib-c/extern_2.c
new file mode 100644
index 000000000..ae87fc3f8
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/extern_2.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+__declspec(dllexport) void extern_fn_3() {
+ printf("extern_fn_3\n");
+ fflush(stdout);
+}
diff --git a/src/test/run-make/raw-dylib-c/lib.rs b/src/test/run-make/raw-dylib-c/lib.rs
new file mode 100644
index 000000000..58f7ccb38
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/lib.rs
@@ -0,0 +1,26 @@
+#![feature(raw_dylib, native_link_modifiers_verbatim)]
+
+#[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")]
+extern {
+ fn extern_fn_1();
+}
+
+#[link(name = "extern_2", kind = "raw-dylib")]
+extern {
+ fn extern_fn_3();
+}
+
+pub fn library_function() {
+ #[link(name = "extern_1", kind = "raw-dylib")]
+ extern { fn extern_fn_2(); }
+
+ unsafe {
+ extern_fn_1();
+ extern_fn_2();
+ extern_fn_3();
+ }
+}
+
+fn main() {
+ library_function();
+}
diff --git a/src/test/run-make/raw-dylib-c/output.txt b/src/test/run-make/raw-dylib-c/output.txt
new file mode 100644
index 000000000..7800cba18
--- /dev/null
+++ b/src/test/run-make/raw-dylib-c/output.txt
@@ -0,0 +1,3 @@
+extern_fn_1
+extern_fn_2; didn't get the rename
+extern_fn_3