Add test for deduplicate native lib in linking

This commit is contained in:
12101111 2021-05-22 19:51:26 +08:00
parent 004614c4b3
commit 8e42fa55db
No known key found for this signature in database
GPG Key ID: 97785FADF38A97DC
5 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# ignore-msvc
-include ../tools.mk
all:
$(RUSTC) depa.rs
$(RUSTC) depb.rs
$(RUSTC) depc.rs
$(RUSTC) empty.rs --cfg bar 2>&1 | $(CGREP) '"-ltesta" "-ltestb" "-ltesta"'
$(RUSTC) empty.rs 2>&1 | $(CGREP) '"-ltesta"'
$(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltestb"'
$(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltesta" "-ltesta"'

View File

@ -0,0 +1,7 @@
#![crate_type = "rlib"]
#[link(name = "testa")]
extern "C" {}
#[link(name = "testa")]
extern "C" {}

View File

@ -0,0 +1,8 @@
#![feature(link_cfg)]
#![crate_type = "rlib"]
#[link(name = "testb", cfg(foo))]
extern "C" {}
#[link(name = "testb", cfg(bar))]
extern "C" {}

View File

@ -0,0 +1,4 @@
#![crate_type = "rlib"]
#[link(name = "testa")]
extern "C" {}

View File

@ -0,0 +1,5 @@
extern crate depa;
extern crate depb;
extern crate depc;
fn main() {}