summaryrefslogtreecommitdiffstats
path: root/tests/run-make/raw-dylib-cross-compilation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/run-make/raw-dylib-cross-compilation
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/raw-dylib-cross-compilation')
-rw-r--r--tests/run-make/raw-dylib-cross-compilation/Makefile22
-rw-r--r--tests/run-make/raw-dylib-cross-compilation/lib.rs20
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/run-make/raw-dylib-cross-compilation/Makefile b/tests/run-make/raw-dylib-cross-compilation/Makefile
new file mode 100644
index 000000000..a8f97edd6
--- /dev/null
+++ b/tests/run-make/raw-dylib-cross-compilation/Makefile
@@ -0,0 +1,22 @@
+# Tests that raw-dylib cross compilation works correctly
+
+# only-gnu
+# needs-i686-dlltool
+# needs-x86_64-dlltool
+
+# i686 dlltool.exe can't product x64 binaries.
+# ignore-i686-pc-windows-gnu
+
+include ../tools.mk
+
+all:
+ # Build as x86 and make sure that we have x86 objects only.
+ $(RUSTC) --crate-type lib --crate-name i686_raw_dylib_test --target i686-pc-windows-gnu lib.rs
+ "$(LLVM_BIN_DIR)"/llvm-objdump -a $(TMPDIR)/libi686_raw_dylib_test.rlib > $(TMPDIR)/i686.objdump.txt
+ $(CGREP) "file format coff-i386" < $(TMPDIR)/i686.objdump.txt
+ $(CGREP) -v "file format coff-x86-64" < $(TMPDIR)/i686.objdump.txt
+ # Build as x64 and make sure that we have x64 objects only.
+ $(RUSTC) --crate-type lib --crate-name x64_raw_dylib_test --target x86_64-pc-windows-gnu lib.rs
+ "$(LLVM_BIN_DIR)"/llvm-objdump -a $(TMPDIR)/libx64_raw_dylib_test.rlib > $(TMPDIR)/x64.objdump.txt
+ $(CGREP) "file format coff-x86-64" < $(TMPDIR)/x64.objdump.txt
+ $(CGREP) -v "file format coff-i386" < $(TMPDIR)/x64.objdump.txt
diff --git a/tests/run-make/raw-dylib-cross-compilation/lib.rs b/tests/run-make/raw-dylib-cross-compilation/lib.rs
new file mode 100644
index 000000000..51bf2ec6b
--- /dev/null
+++ b/tests/run-make/raw-dylib-cross-compilation/lib.rs
@@ -0,0 +1,20 @@
+#![feature(raw_dylib)]
+#![feature(no_core, lang_items)]
+#![no_std]
+#![no_core]
+#![crate_type = "lib"]
+
+// This is needed because of #![no_core]:
+#[lang = "sized"]
+trait Sized {}
+
+#[link(name = "extern_1", kind = "raw-dylib")]
+extern {
+ fn extern_fn();
+}
+
+pub fn extern_fn_caller() {
+ unsafe {
+ extern_fn();
+ }
+}