From 08990e5c7554d4d6a0440debc2edc99c8e9565c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 16 Jul 2020 22:45:41 +0200 Subject: [PATCH] MinGW: disable self-contained mode when cross compiling When cross compiling users have to provide own linker and libraries anyway. Using rust provided MinGW crt objects is harmful here and has no benefits. --- src/librustc_codegen_ssa/back/link.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 3adaa07db91b..63ed094acb75 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1295,7 +1295,9 @@ fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool { Some(CrtObjectsFallback::Musl) => sess.crt_static(Some(crate_type)), // FIXME: Find some heuristic for "native mingw toolchain is available", // likely based on `get_crt_libs_path` (https://github.com/rust-lang/rust/pull/67429). - Some(CrtObjectsFallback::Mingw) => sess.target.target.target_vendor != "uwp", + Some(CrtObjectsFallback::Mingw) => { + sess.host == sess.target.target && sess.target.target.target_vendor != "uwp" + } // FIXME: Figure out cases in which WASM needs to link with a native toolchain. Some(CrtObjectsFallback::Wasm) => true, None => false,