From 688ed033f0e4ceaee40fef40e13e4d3db70dddd3 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Wed, 20 Sep 2023 10:35:41 +0200 Subject: [PATCH] Mirror clang's link stage on Windows. Fixes problem discussed in #811. [Also deduplicate clang --target argument on Windows, because it's passed later on in the "// Target flags" section.] --- src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aa5eef4b7..9a9975d56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1172,6 +1172,11 @@ impl Build { atlmfc_lib.display() )); } + + if compiler.family == ToolFamily::Clang { + // Mirror what clang does at link stage + self.print(&format_args!("cargo:rustc-link-arg=-defaultib:oldnames")); + } } if self.link_lib_modifiers.is_empty() { @@ -1758,13 +1763,6 @@ 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)