forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for shared-generics x dylibs (rust-lang#67276).
- Loading branch information
1 parent
31095d7
commit ce6995f
Showing
7 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This test makes sure all generic instances get re-exported from Rust dylibs for use by | ||
# `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`) | ||
# which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is | ||
# supposed to re-export both these instances, and then there are `instance_user_a_rlib` and | ||
# `instance_user_b_rlib` which each rely on a specific instance to be available. | ||
# | ||
# In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does | ||
# not export both then we'll get an `undefined reference` error for one of the instances. | ||
# | ||
# This is regression test for https://github.com/rust-lang/rust/issues/67276. | ||
|
||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
COMMON_ARGS=-Cprefer-dynamic -Zshare-generics=yes -Ccodegen-units=1 -Zsymbol-mangling-version=v0 | ||
|
||
all: | ||
$(RUSTC) instance_provider_a.rs $(COMMON_ARGS) --crate-type=rlib | ||
$(RUSTC) instance_provider_b.rs $(COMMON_ARGS) --crate-type=rlib | ||
$(RUSTC) instance_user_dylib.rs $(COMMON_ARGS) --crate-type=dylib | ||
$(RUSTC) instance_user_a_rlib.rs $(COMMON_ARGS) --crate-type=rlib | ||
$(RUSTC) instance_user_b_rlib.rs $(COMMON_ARGS) --crate-type=rlib | ||
$(RUSTC) linked_leaf.rs $(COMMON_ARGS) --crate-type=bin |
6 changes: 6 additions & 0 deletions
6
src/test/run-make-fulldeps/share-generics-dylib/instance_provider_a.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use std::cell::Cell; | ||
|
||
pub fn foo() { | ||
let a: Cell<i32> = Cell::new(1); | ||
a.set(123); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/test/run-make-fulldeps/share-generics-dylib/instance_provider_b.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use std::cell::Cell; | ||
|
||
pub fn foo() { | ||
let b: Cell<i32> = Cell::new(1); | ||
b.set(123); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/run-make-fulldeps/share-generics-dylib/instance_user_a_rlib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
extern crate instance_provider_a as upstream; | ||
use std::cell::Cell; | ||
|
||
pub fn foo() { | ||
upstream::foo(); | ||
|
||
let b: Cell<i32> = Cell::new(1); | ||
b.set(123); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/run-make-fulldeps/share-generics-dylib/instance_user_b_rlib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
extern crate instance_provider_b as upstream; | ||
use std::cell::Cell; | ||
|
||
pub fn foo() { | ||
upstream::foo(); | ||
|
||
let b: Cell<i32> = Cell::new(1); | ||
b.set(123); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/test/run-make-fulldeps/share-generics-dylib/instance_user_dylib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extern crate instance_provider_a; | ||
extern crate instance_provider_b; | ||
|
||
pub fn foo() { | ||
instance_provider_a::foo(); | ||
instance_provider_b::foo(); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/run-make-fulldeps/share-generics-dylib/linked_leaf.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extern crate instance_user_dylib; | ||
extern crate instance_user_a_rlib; | ||
extern crate instance_user_b_rlib; | ||
|
||
use std::cell::Cell; | ||
|
||
fn main() { | ||
|
||
instance_user_a_rlib::foo(); | ||
instance_user_b_rlib::foo(); | ||
instance_user_dylib::foo(); | ||
|
||
let a: Cell<i32> = Cell::new(1); | ||
a.set(123); | ||
} |