Skip to content

Commit e40faef

Browse files
committed
Deduplicate native libs before they are passed to the linker
1 parent 5f304a5 commit e40faef

File tree

1 file changed

+8
-0
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+8
-0
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,11 @@ fn add_local_native_libraries(
18031803
codegen_results.crate_info.used_libraries.iter().filter(|l| relevant_lib(sess, l));
18041804

18051805
let search_path = archive_search_paths(sess);
1806+
let mut last = (NativeLibKind::Unspecified, None);
18061807
for lib in relevant_libs {
1808+
// Skip if this library is the same as the last.
1809+
last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
1810+
18071811
let name = match lib.name {
18081812
Some(l) => l,
18091813
None => continue,
@@ -2127,8 +2131,12 @@ fn add_upstream_native_libraries(
21272131
.expect("failed to find crate type in dependency format list");
21282132

21292133
let crates = &codegen_results.crate_info.used_crates_static;
2134+
let mut last = (NativeLibKind::Unspecified, None);
21302135
for &(cnum, _) in crates {
21312136
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
2137+
// Skip if this library is the same as the last.
2138+
last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
2139+
21322140
let name = match lib.name {
21332141
Some(l) => l,
21342142
None => continue,

0 commit comments

Comments
 (0)