Skip to content

Commit ce6995f

Browse files
Add regression test for shared-generics x dylibs (#67276).
1 parent 31095d7 commit ce6995f

File tree

7 files changed

+74
-0
lines changed

7 files changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This test makes sure all generic instances get re-exported from Rust dylibs for use by
2+
# `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
3+
# which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is
4+
# supposed to re-export both these instances, and then there are `instance_user_a_rlib` and
5+
# `instance_user_b_rlib` which each rely on a specific instance to be available.
6+
#
7+
# In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does
8+
# not export both then we'll get an `undefined reference` error for one of the instances.
9+
#
10+
# This is regression test for https://github.com/rust-lang/rust/issues/67276.
11+
12+
-include ../../run-make-fulldeps/tools.mk
13+
14+
COMMON_ARGS=-Cprefer-dynamic -Zshare-generics=yes -Ccodegen-units=1 -Zsymbol-mangling-version=v0
15+
16+
all:
17+
$(RUSTC) instance_provider_a.rs $(COMMON_ARGS) --crate-type=rlib
18+
$(RUSTC) instance_provider_b.rs $(COMMON_ARGS) --crate-type=rlib
19+
$(RUSTC) instance_user_dylib.rs $(COMMON_ARGS) --crate-type=dylib
20+
$(RUSTC) instance_user_a_rlib.rs $(COMMON_ARGS) --crate-type=rlib
21+
$(RUSTC) instance_user_b_rlib.rs $(COMMON_ARGS) --crate-type=rlib
22+
$(RUSTC) linked_leaf.rs $(COMMON_ARGS) --crate-type=bin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use std::cell::Cell;
2+
3+
pub fn foo() {
4+
let a: Cell<i32> = Cell::new(1);
5+
a.set(123);
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use std::cell::Cell;
2+
3+
pub fn foo() {
4+
let b: Cell<i32> = Cell::new(1);
5+
b.set(123);
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extern crate instance_provider_a as upstream;
2+
use std::cell::Cell;
3+
4+
pub fn foo() {
5+
upstream::foo();
6+
7+
let b: Cell<i32> = Cell::new(1);
8+
b.set(123);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extern crate instance_provider_b as upstream;
2+
use std::cell::Cell;
3+
4+
pub fn foo() {
5+
upstream::foo();
6+
7+
let b: Cell<i32> = Cell::new(1);
8+
b.set(123);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extern crate instance_provider_a;
2+
extern crate instance_provider_b;
3+
4+
pub fn foo() {
5+
instance_provider_a::foo();
6+
instance_provider_b::foo();
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extern crate instance_user_dylib;
2+
extern crate instance_user_a_rlib;
3+
extern crate instance_user_b_rlib;
4+
5+
use std::cell::Cell;
6+
7+
fn main() {
8+
9+
instance_user_a_rlib::foo();
10+
instance_user_b_rlib::foo();
11+
instance_user_dylib::foo();
12+
13+
let a: Cell<i32> = Cell::new(1);
14+
a.set(123);
15+
}

0 commit comments

Comments
 (0)