File tree 3 files changed +16
-1
lines changed
compiler/rustc_codegen_ssa/src/back
tests/run-make/print-native-static-libs
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(
1392
1392
let mut lib_args: Vec < _ > = all_native_libs
1393
1393
. iter ( )
1394
1394
. 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 )
1395
1400
. filter_map ( |lib| {
1396
1401
let name = lib. name ;
1397
1402
match lib. kind {
Original file line number Diff line number Diff line change @@ -5,11 +5,15 @@ include ../tools.mk
5
5
6
6
all :
7
7
$(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 \
9
9
| grep ' note: native-static-libs: ' \
10
10
| sed ' s/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR ) /libs.txt
11
11
12
12
cat $(TMPDIR)/libs.txt | grep -F "glib-2.0" # in bar.rs
13
13
cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs
14
14
cat $(TMPDIR)/libs.txt | grep -F "bar_cli"
15
15
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 {
3
3
// Obviously makes no sense but...
4
4
unsafe {
5
5
g_free ( std:: ptr:: null_mut ( ) ) ;
6
+ g_free2 ( std:: ptr:: null_mut ( ) ) ;
6
7
}
7
8
left + right
8
9
}
@@ -11,3 +12,8 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
11
12
extern "C" {
12
13
fn g_free ( p : * mut ( ) ) ;
13
14
}
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