Skip to content

Commit

Permalink
Mirror clang's link stage on Windows.
Browse files Browse the repository at this point in the history
Fixes problem discussed in rust-lang#811.

[Also deduplicate clang --target argument on Windows, because it's
passed later on in the "// Target flags" section.]
  • Loading branch information
dot-asm committed Sep 27, 2023
1 parent 5b91c7b commit 72ff04f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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=-defaultlib:oldnames"));
}
}

if self.link_lib_modifiers.is_empty() {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72ff04f

Please sign in to comment.