From e84367bb647b9e45dae4d0435aa1a689a4eebbb1 Mon Sep 17 00:00:00 2001 From: Andy Polyakov <9038069+dot-asm@users.noreply.github.com> Date: Sat, 22 Jul 2023 00:27:33 +0200 Subject: [PATCH] Disambiguate Windows run-times when using clang to compile. (#825) --- src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b2b0ad728..2a192df74 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1642,6 +1642,13 @@ impl Build { cmd.push_opt_unless_duplicate(format!("-O{}", opt_level).into()); } + if cmd.family == ToolFamily::Clang && target.contains("windows") { + // Disambiguate mingw and msvc on Windows. Problem is that + // depending on the origin clang can default to a mismatchig + // run-time. + cmd.push_cc_arg(format!("--target={}", target).into()); + } + if cmd.family == ToolFamily::Clang && target.contains("android") { // For compatibility with code that doesn't use pre-defined `__ANDROID__` macro. // If compiler used via ndk-build or cmake (officially supported build methods) @@ -2575,6 +2582,10 @@ impl Build { } } + if target.contains("msvc") && tool.family == ToolFamily::Gnu { + println!("cargo:warning=GNU compiler is not supported for this target"); + } + Ok(tool) }