diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/run-make/raw-dylib-link-ordinal | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/raw-dylib-link-ordinal')
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/Makefile | 22 | ||||
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/driver.rs | 5 | ||||
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/exporter.c | 12 | ||||
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/exporter.def | 5 | ||||
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/lib.rs | 21 | ||||
-rw-r--r-- | tests/run-make/raw-dylib-link-ordinal/output.txt | 3 |
6 files changed, 68 insertions, 0 deletions
diff --git a/tests/run-make/raw-dylib-link-ordinal/Makefile b/tests/run-make/raw-dylib-link-ordinal/Makefile new file mode 100644 index 000000000..b55a94dbc --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/Makefile @@ -0,0 +1,22 @@ +# Test the behavior of #[link(.., kind = "raw-dylib")] and #[link_ordinal] 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)" + $(call COMPILE_OBJ,"$(TMPDIR)"/exporter.obj,exporter.c) +ifdef IS_MSVC + $(CC) "$(TMPDIR)"/exporter.obj exporter.def -link -dll -out:"$(TMPDIR)"/exporter.dll -noimplib +else + $(CC) "$(TMPDIR)"/exporter.obj exporter.def -shared -o "$(TMPDIR)"/exporter.dll +endif + "$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/output.txt output.txt +else + $(DIFF) output.txt "$(TMPDIR)"/output.txt +endif diff --git a/tests/run-make/raw-dylib-link-ordinal/driver.rs b/tests/run-make/raw-dylib-link-ordinal/driver.rs new file mode 100644 index 000000000..4059ede11 --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/driver.rs @@ -0,0 +1,5 @@ +extern crate raw_dylib_test; + +fn main() { + raw_dylib_test::library_function(); +} diff --git a/tests/run-make/raw-dylib-link-ordinal/exporter.c b/tests/run-make/raw-dylib-link-ordinal/exporter.c new file mode 100644 index 000000000..aabf32ff1 --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/exporter.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +void exported_function() { + printf("exported_function\n"); +} + +int exported_variable = 0; + +void print_exported_variable() { + printf("exported_variable value: %d\n", exported_variable); + fflush(stdout); +} diff --git a/tests/run-make/raw-dylib-link-ordinal/exporter.def b/tests/run-make/raw-dylib-link-ordinal/exporter.def new file mode 100644 index 000000000..5d87c580a --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/exporter.def @@ -0,0 +1,5 @@ +LIBRARY exporter +EXPORTS + exported_function @13 NONAME + exported_variable @5 NONAME + print_exported_variable @9 NONAME diff --git a/tests/run-make/raw-dylib-link-ordinal/lib.rs b/tests/run-make/raw-dylib-link-ordinal/lib.rs new file mode 100644 index 000000000..bb25ac64c --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/lib.rs @@ -0,0 +1,21 @@ +#![cfg_attr(target_arch = "x86", feature(raw_dylib))] + +#[link(name = "exporter", kind = "raw-dylib")] +extern { + #[link_ordinal(13)] + fn imported_function(); + #[link_ordinal(5)] + static mut imported_variable: i32; + #[link_ordinal(9)] + fn print_imported_variable(); +} + +pub fn library_function() { + unsafe { + imported_function(); + imported_variable = 42; + print_imported_variable(); + imported_variable = -42; + print_imported_variable(); + } +} diff --git a/tests/run-make/raw-dylib-link-ordinal/output.txt b/tests/run-make/raw-dylib-link-ordinal/output.txt new file mode 100644 index 000000000..a4b2031d9 --- /dev/null +++ b/tests/run-make/raw-dylib-link-ordinal/output.txt @@ -0,0 +1,3 @@ +exported_function +exported_variable value: 42 +exported_variable value: -42 |