Skip to content

Commit 172ba70

Browse files
committed
A collection of test cases showing how the new -C prefer-dynamic=crate,... flag can be used to resolve issue 82151.
These differ from the diamonds-*.rs in a couple of ways: * The most foundational library is being compiled to multiple crate output types, and * The most foundational library is being compiled to a `cdylib`, not a `dylib`. These two details seemed to be critical for reproducing the exact set of unfortunate link-time behaviors that we observed on issue 82151, as illustrated by the family of tests named `issue-82151-serverctl-*.rs`. ---- issue-82151-serverctl-prefdyn.rs works around ld-binary specific details by adding extra normalization to test, including normalizing stage number in output.
1 parent 8d63ba2 commit 172ba70

19 files changed

+335
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![crate_name="bar"]
2+
#![crate_type="rlib"]
3+
#![crate_type="cdylib"]
4+
5+
pub struct Bar;
6+
7+
pub fn bar() -> Bar {
8+
Bar
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![crate_name="bar"]
2+
#![crate_type="rlib"]
3+
#![crate_type="cdylib"]
4+
5+
// no-prefer-dynamic
6+
7+
pub struct Bar;
8+
9+
pub fn bar() -> Bar {
10+
Bar
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![crate_name="bar"]
2+
#![crate_type="rlib"]
3+
#![crate_type="cdylib"]
4+
5+
// no-prefer-dynamic
6+
// compile-flags: -C prefer-dynamic
7+
8+
pub struct Bar;
9+
10+
pub fn bar() -> Bar {
11+
Bar
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![crate_name="bar"]
2+
#![crate_type="rlib"]
3+
#![crate_type="cdylib"]
4+
5+
// no-prefer-dynamic
6+
// compile-flags: -C prefer-dynamic=std -Z prefer-dynamic-std
7+
8+
pub struct Bar;
9+
10+
pub fn bar() -> Bar {
11+
Bar
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![crate_name="bar"]
2+
#![crate_type="rlib"]
3+
#![crate_type="cdylib"]
4+
5+
// no-prefer-dynamic
6+
// compile-flags: -C prefer-dynamic=shared,std -Z prefer-dynamic-subset
7+
8+
pub struct Bar;
9+
10+
pub fn bar() -> Bar {
11+
Bar
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![crate_name="foo"]
2+
#![crate_type="rlib"]
3+
4+
// no-prefer-dynamic
5+
6+
extern crate bar;
7+
8+
pub struct Foo;
9+
pub use bar::bar;
10+
11+
pub fn foo() -> Foo {
12+
Foo
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_name="foo"]
2+
#![crate_type="rlib"]
3+
4+
// no-prefer-dynamic
5+
// compile-flags: -C prefer-dynamic
6+
7+
extern crate bar;
8+
9+
pub struct Foo;
10+
pub use bar::bar;
11+
12+
pub fn foo() -> Foo {
13+
Foo
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_name="foo"]
2+
#![crate_type="rlib"]
3+
4+
// no-prefer-dynamic
5+
// compile-flags: -C prefer-dynamic=std -Z prefer-dynamic-std
6+
7+
extern crate bar;
8+
9+
pub struct Foo;
10+
pub use bar::bar;
11+
12+
pub fn foo() -> Foo {
13+
Foo
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_name="foo"]
2+
#![crate_type="rlib"]
3+
4+
// no-prefer-dynamic
5+
// compile-flags: -C prefer-dynamic=shared,std -Z prefer-dynamic-subset
6+
7+
extern crate bar;
8+
9+
pub struct Foo;
10+
pub use bar::bar;
11+
12+
pub fn foo() -> Foo {
13+
Foo
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![crate_name="shared"]
2+
#![crate_type="dylib"]
3+
4+
// no-prefer-dynamic
5+
6+
extern crate foo;
7+
8+
pub struct Test;
9+
10+
impl Test {
11+
pub fn new() -> Self {
12+
let _ = foo::foo();
13+
let _ = foo::bar();
14+
// let _ = bar::bar();
15+
Self
16+
}
17+
}

0 commit comments

Comments
 (0)