This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
compiler/rustc_codegen_ssa/src/back
tests/run-make/print-native-static-libs Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1392,6 +1392,11 @@ fn print_native_static_libs(
13921392 let mut lib_args: Vec < _ > = all_native_libs
13931393 . iter ( )
13941394 . filter ( |l| relevant_lib ( sess, l) )
1395+ // Deduplication of successive repeated libraries, see rust-lang/rust#113209
1396+ //
1397+ // note: we don't use PartialEq/Eq because NativeLib transitively depends on local
1398+ // elements like spans, which we don't care about and would make the deduplication impossible
1399+ . dedup_by ( |l1, l2| l1. name == l2. name && l1. kind == l2. kind && l1. verbatim == l2. verbatim )
13951400 . filter_map ( |lib| {
13961401 let name = lib. name ;
13971402 match lib. kind {
Original file line number Diff line number Diff line change @@ -5,11 +5,15 @@ include ../tools.mk
55
66all :
77 $(RUSTC ) --crate-type rlib -lbar_cli bar.rs
8- $(RUSTC ) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \
8+ $(RUSTC ) foo.rs -lfoo_cli -lfoo_cli - -crate-type staticlib --print native-static-libs 2>&1 \
99 | grep ' note: native-static-libs: ' \
1010 | sed ' s/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR ) /libs.txt
1111
1212 cat $(TMPDIR)/libs.txt | grep -F "glib-2.0" # in bar.rs
1313 cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs
1414 cat $(TMPDIR)/libs.txt | grep -F "bar_cli"
1515 cat $(TMPDIR)/libs.txt | grep -F "foo_cli"
16+
17+ # make sure that foo_cli and glib-2.0 are not consecutively present
18+ cat $(TMPDIR)/libs.txt | grep -Fv "foo_cli -lfoo_cli"
19+ cat $(TMPDIR)/libs.txt | grep -Fv "glib-2.0 -lglib-2.0"
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
33 // Obviously makes no sense but...
44 unsafe {
55 g_free ( std:: ptr:: null_mut ( ) ) ;
6+ g_free2 ( std:: ptr:: null_mut ( ) ) ;
67 }
78 left + right
89}
@@ -11,3 +12,8 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
1112extern "C" {
1213 fn g_free ( p : * mut ( ) ) ;
1314}
15+
16+ #[ link( name = "glib-2.0" ) ]
17+ extern "C" {
18+ fn g_free2 ( p : * mut ( ) ) ;
19+ }
You can’t perform that action at this time.
0 commit comments