From 3713ed67fd46b113948ed98170325a7225bdf331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 28 Feb 2020 14:15:06 +0100 Subject: [PATCH 1/2] Improve MinGW detection when cross compiling --- src/bootstrap/dist.rs | 9 ++++++++- src/librustc_target/spec/i686_pc_windows_gnu.rs | 1 + src/librustc_target/spec/x86_64_pc_windows_gnu.rs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 8003d8906e8..d2f2bc56bdc 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -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"); diff --git a/src/librustc_target/spec/i686_pc_windows_gnu.rs b/src/librustc_target/spec/i686_pc_windows_gnu.rs index 35fbf875731..2091902d7ce 100644 --- a/src/librustc_target/spec/i686_pc_windows_gnu.rs +++ b/src/librustc_target/spec/i686_pc_windows_gnu.rs @@ -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. diff --git a/src/librustc_target/spec/x86_64_pc_windows_gnu.rs b/src/librustc_target/spec/x86_64_pc_windows_gnu.rs index 8f523a3b6c6..3d3acc682de 100644 --- a/src/librustc_target/spec/x86_64_pc_windows_gnu.rs +++ b/src/librustc_target/spec/x86_64_pc_windows_gnu.rs @@ -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(), From cdb69556593c33023ca516795322ba75e6444b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 29 Feb 2020 11:54:33 +0100 Subject: [PATCH 2/2] Update src/bootstrap/dist.rs Co-Authored-By: kennytm --- src/bootstrap/dist.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index d2f2bc56bdc..6d7ae7e91a6 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -241,7 +241,7 @@ fn make_win_dist( } else { "gcc.exe" }; - let target_tools = [&compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"]; + 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");