Skip to content

Commit

Permalink
Rollup merge of rust-lang#126943 - Urgau:dedup-all, r=petrochenkov
Browse files Browse the repository at this point in the history
De-duplicate all consecutive native libs regardless of their options

Address rust-lang#126913 (comment) by no longer de-duplicating based on the "options" but by only looking at the generated link args, as to avoid consecutive libs that originated from different native-lib with different options (like `raw-dylib` on Windows) but isn't relevant for `--print=native-static-libs`.

r? `@petrochenkov`
  • Loading branch information
compiler-errors committed Jun 25, 2024
2 parents f0339ac + 604caa0 commit 095645c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 2 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,11 +1490,6 @@ fn print_native_static_libs(
let mut lib_args: Vec<_> = all_native_libs
.iter()
.filter(|l| relevant_lib(sess, l))
// Deduplication of successive repeated libraries, see rust-lang/rust#113209
//
// note: we don't use PartialEq/Eq because NativeLib transitively depends on local
// elements like spans, which we don't care about and would make the deduplication impossible
.dedup_by(|l1, l2| l1.name == l2.name && l1.kind == l2.kind && l1.verbatim == l2.verbatim)
.filter_map(|lib| {
let name = lib.name;
match lib.kind {
Expand All @@ -1521,6 +1516,8 @@ fn print_native_static_libs(
| NativeLibKind::RawDylib => None,
}
})
// deduplication of consecutive repeated libraries, see rust-lang/rust#113209
.dedup()
.collect();
for path in all_rust_dylibs {
// FIXME deduplicate with add_dynamic_crate
Expand Down
6 changes: 6 additions & 0 deletions tests/run-make/print-native-static-libs/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ extern "C" {
extern "C" {
fn g_free2(p: *mut ());
}

#[cfg(windows)]
#[link(name = "glib-2.0", kind = "raw-dylib")]
extern "C" {
fn g_free3(p: *mut ());
}

0 comments on commit 095645c

Please sign in to comment.