Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate native libs before they are passed to the linker #84794

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down