rewrite raw-dylib-cross-compilation to rmake

This commit is contained in:
Oneirical 2024-06-19 11:31:13 -04:00
parent a4f3e5f725
commit ec1ed26263
3 changed files with 41 additions and 21 deletions

View File

@ -136,7 +136,6 @@ run-make/profile/Makefile
run-make/prune-link-args/Makefile
run-make/raw-dylib-alt-calling-convention/Makefile
run-make/raw-dylib-c/Makefile
run-make/raw-dylib-cross-compilation/Makefile
run-make/raw-dylib-custom-dlltool/Makefile
run-make/raw-dylib-import-name-type/Makefile
run-make/raw-dylib-inline-cross-dylib/Makefile

View File

@ -1,20 +0,0 @@
# Tests that raw-dylib cross compilation works correctly
# needs-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

View File

@ -0,0 +1,41 @@
// When cross-compiling using `raw-dylib`, rustc would try to fetch some
// very specific `dlltool` to complete the cross-compilation (such as `i686-w64-mingw32-dlltool`)
// when Windows only calls it `dlltool`. This test performs some cross-compilation in a
// way that previously failed due to this bug, and checks that it succeeds.
// See https://github.com/rust-lang/rust/pull/108355
//@ ignore-i686-pc-windows-msvc
// Reason: dlltool on this distribution is unable to produce x64 binaries
//@ needs-dlltool
// Reason: this is the utility being checked by this test
use run_make_support::{llvm_objdump, rust_lib_name, rustc};
fn main() {
// 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")
.input("lib.rs")
.run();
llvm_objdump()
.arg("-a")
.input(rust_lib_name("i686_raw_dylib_test"))
.run()
.assert_stdout_contains("file format coff-i386")
.assert_stdout_not_contains("file format coff-x86-64");
// 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")
.input("lib.rs")
.run();
llvm_objdump()
.arg("-a")
.input(rust_lib_name("i686_raw_dylib_test"))
.run()
.assert_stdout_not_contains("file format coff-i386")
.assert_stdout_contains("file format coff-x86-64");
}