Skip to content
Merged
Changes from 1 commit
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
14 changes: 8 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,13 +1805,14 @@ fn add_local_native_libraries(
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,
};

// Skip if this library is the same as the last.
last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not strictly necessary for the fix, but let's leave it for consistency.
It also improves deduplication in the (unlikely) case of #[link(name = "foo")] #[link(wasm_import_module = "...")] #[link(name = "foo")].


let verbatim = lib.verbatim.unwrap_or(false);
match lib.kind {
NativeLibKind::Dylib { as_needed } => {
Expand Down Expand Up @@ -2144,16 +2145,17 @@ fn add_upstream_native_libraries(
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,
};
if !relevant_lib(sess, &lib) {
continue;
}

// Skip if this library is the same as the last.
last = if (lib.kind, lib.name) == last { continue } else { (lib.kind, lib.name) };

let verbatim = lib.verbatim.unwrap_or(false);
match lib.kind {
NativeLibKind::Dylib { as_needed } => {
Expand Down