From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/run-make/raw-dylib-c/Makefile | 28 ++++++++++++++++++++++++++++ src/test/run-make/raw-dylib-c/driver.rs | 5 +++++ src/test/run-make/raw-dylib-c/extern_1.c | 16 ++++++++++++++++ src/test/run-make/raw-dylib-c/extern_2.c | 6 ++++++ src/test/run-make/raw-dylib-c/lib.rs | 26 ++++++++++++++++++++++++++ src/test/run-make/raw-dylib-c/output.txt | 3 +++ 6 files changed, 84 insertions(+) create mode 100644 src/test/run-make/raw-dylib-c/Makefile create mode 100644 src/test/run-make/raw-dylib-c/driver.rs create mode 100644 src/test/run-make/raw-dylib-c/extern_1.c create mode 100644 src/test/run-make/raw-dylib-c/extern_2.c create mode 100644 src/test/run-make/raw-dylib-c/lib.rs create mode 100644 src/test/run-make/raw-dylib-c/output.txt (limited to 'src/test/run-make/raw-dylib-c') 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 + +__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 + +__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 -- cgit v1.2.3