diff options
| author | Chris Denton <christophersdenton@gmail.com> | 2021-05-01 20:59:26 +0100 |
|---|---|---|
| committer | Chris Denton <christophersdenton@gmail.com> | 2021-05-01 21:30:26 +0100 |
| commit | e40faeffa2d9e980778fb46973f8d0eb090526a9 (patch) | |
| tree | 7cff0215cf2915cb29fe0ddd6e2dbc004ef5525c | |
| parent | 5f304a5d7908d9dd55dda3baadd3cf564d907369 (diff) | |
| download | rust-e40faeffa2d9e980778fb46973f8d0eb090526a9.tar.gz rust-e40faeffa2d9e980778fb46973f8d0eb090526a9.zip | |
Deduplicate native libs before they are passed to the linker
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index ea75943d6f3..dcdd0910aa6 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1803,7 +1803,11 @@ fn add_local_native_libraries( codegen_results.crate_info.used_libraries.iter().filter(|l| relevant_lib(sess, l)); let search_path = archive_search_paths(sess); + let mut last = (NativeLibKind::Unspecified, None); for lib in relevant_libs { + // Skip if this library is the same as the last. + last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) }; + let name = match lib.name { Some(l) => l, None => continue, @@ -2127,8 +2131,12 @@ fn add_upstream_native_libraries( .expect("failed to find crate type in dependency format list"); let crates = &codegen_results.crate_info.used_crates_static; + let mut last = (NativeLibKind::Unspecified, None); for &(cnum, _) in crates { for lib in codegen_results.crate_info.native_libraries[&cnum].iter() { + // Skip if this library is the same as the last. + last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) }; + let name = match lib.name { Some(l) => l, None => continue, |
