Rollup merge of #69549 - mati865:mingw, r=kennytm

Improve MinGW detection when cross compiling

Official mingw-w64 builds, MSYS2 and LLVM MinGW provide both `gcc.exe` and `$ARCH-w64-mingw32-gcc.exe` so they should not regress but I included CI changes to verify it though `@bors try` (I don't have permission).

This change will come handy when cross compiling from Linux or Cygwin since they use `gcc` as native compiler and `$ARCH-w64-mingw32-gcc.exe` for MinGW. This means users will no longer have to override the linker.
This commit is contained in:
Yuki Okushi 2020-03-01 19:28:07 +09:00 committed by GitHub
commit 559e5ab7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -234,7 +234,14 @@ fn make_win_dist(
}
}
let target_tools = ["gcc.exe", "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
let compiler = if target_triple == "i686-pc-windows-gnu" {
"i686-w64-mingw32-gcc.exe"
} else if target_triple == "x86_64-pc-windows-gnu" {
"x86_64-w64-mingw32-gcc.exe"
} else {
"gcc.exe"
};
let target_tools = [compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
let mut rustc_dlls = vec!["libwinpthread-1.dll"];
if target_triple.starts_with("i686-") {
rustc_dlls.push("libgcc_s_dw2-1.dll");

View File

@ -5,6 +5,7 @@ pub fn target() -> TargetResult {
base.cpu = "pentium4".to_string();
base.max_atomic_width = Some(64);
base.eliminate_frame_pointer = false; // Required for backtraces
base.linker = Some("i686-w64-mingw32-gcc".to_string());
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.

View File

@ -5,6 +5,7 @@ pub fn target() -> TargetResult {
base.cpu = "x86-64".to_string();
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
base.max_atomic_width = Some(64);
base.linker = Some("x86_64-w64-mingw32-gcc".to_string());
Ok(Target {
llvm_target: "x86_64-pc-windows-gnu".to_string(),