forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#108355 - dpaoliello:dlltoolm, r=michaelwoerister
Fix cross-compiling with dlltool for raw-dylib Fix for rust-lang#103939 Issue Details: When attempting to cross-compile using the `raw-dylib` feature and the GNU toolchain, rustc would attempt to find a cross-compiling version of dlltool (e.g., `i686-w64-mingw32-dlltool`). The has two issues 1) on Windows dlltool is always `dlltool` (no cross-compiling named versions exist) and 2) it only supported compiling to i686 and x86_64 resulting in ARM 32 and 64 compiling as x86_64. Fix Details: * On Windows always use the normal `dlltool` binary. * Add the ARM64 cross-compiling dlltool name (support for this is coming: https://sourceware.org/bugzilla/show_bug.cgi?id=29964) * Provide the `-m` argument to dlltool to indicate the target machine type. (This is the first of two PRs to fix the remaining issues for the `raw-dylib` feature (rust-lang#58713) that is blocking stabilization (rust-lang#104218))
- Loading branch information
Showing
9 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ../../run-make-fulldeps/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |