Skip to content

Commit c641a8c

Browse files
committed
Add run-make-fulldeps test case
1 parent c56f128 commit c641a8c

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-include ../tools.mk
2+
RUSTC_FLAGS = \
3+
-l static=bar \
4+
-l foo \
5+
-l static=baz \
6+
-l foo \
7+
-Z print-link-args
8+
9+
all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
10+
$(RUSTC) $(RUSTC_FLAGS) main.rs
11+
$(call RUN,main)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2019 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
void bar() {
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2019 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern void foo1();
12+
extern void foo2();
13+
14+
void baz() {
15+
foo1();
16+
foo2();
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2019 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
void foo1() {}
12+
void foo2() {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2019 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// rustc will remove one of the two redundant references to foo below. Depending on which one gets
12+
// removed, we'll get a linker error on SOME platforms (like Linux). On these platforms, when a
13+
// library is referenced, the linker will only pull in the symbols needed _at that point in time_.
14+
// If a later library depends on additional symbols from the library, they will not have been
15+
// pulled in, and you'll get undefined symbols errors.
16+
//
17+
// So in this example, we need to ensure that rustc keeps the _later_ reference to foo, and not the
18+
// former one.
19+
20+
extern "C" {
21+
fn bar();
22+
fn baz();
23+
}
24+
25+
fn main() {
26+
unsafe {
27+
bar();
28+
baz();
29+
}
30+
}

0 commit comments

Comments
 (0)