diff options
| author | Douglas Creager <dcreager@github.com> | 2019-03-07 15:12:48 -0500 |
|---|---|---|
| committer | Douglas Creager <dcreager@dcreager.net> | 2019-03-11 20:14:56 -0400 |
| commit | c641a8c424e0d3fea16f41863d216c1ec0642c82 (patch) | |
| tree | f9741500639844448cd5df07c8c338bbcc9c21ff | |
| parent | c56f12833837648d1a4ef40b714efea9c309f8c4 (diff) | |
| download | rust-c641a8c424e0d3fea16f41863d216c1ec0642c82.tar.gz rust-c641a8c424e0d3fea16f41863d216c1ec0642c82.zip | |
Add run-make-fulldeps test case
| -rw-r--r-- | src/test/run-make-fulldeps/redundant-libs/Makefile | 11 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/redundant-libs/bar.c | 12 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/redundant-libs/baz.c | 17 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/redundant-libs/foo.c | 12 | ||||
| -rw-r--r-- | src/test/run-make-fulldeps/redundant-libs/main.rs | 30 |
5 files changed, 82 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/redundant-libs/Makefile b/src/test/run-make-fulldeps/redundant-libs/Makefile new file mode 100644 index 00000000000..f756dc16590 --- /dev/null +++ b/src/test/run-make-fulldeps/redundant-libs/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk +RUSTC_FLAGS = \ + -l static=bar \ + -l foo \ + -l static=baz \ + -l foo \ + -Z print-link-args + +all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz) + $(RUSTC) $(RUSTC_FLAGS) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/redundant-libs/bar.c b/src/test/run-make-fulldeps/redundant-libs/bar.c new file mode 100644 index 00000000000..78ddeb454db --- /dev/null +++ b/src/test/run-make-fulldeps/redundant-libs/bar.c @@ -0,0 +1,12 @@ +// Copyright 2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void bar() { +} diff --git a/src/test/run-make-fulldeps/redundant-libs/baz.c b/src/test/run-make-fulldeps/redundant-libs/baz.c new file mode 100644 index 00000000000..4ec0e9adc67 --- /dev/null +++ b/src/test/run-make-fulldeps/redundant-libs/baz.c @@ -0,0 +1,17 @@ +// Copyright 2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void foo1(); +extern void foo2(); + +void baz() { + foo1(); + foo2(); +} diff --git a/src/test/run-make-fulldeps/redundant-libs/foo.c b/src/test/run-make-fulldeps/redundant-libs/foo.c new file mode 100644 index 00000000000..d5b28210dff --- /dev/null +++ b/src/test/run-make-fulldeps/redundant-libs/foo.c @@ -0,0 +1,12 @@ +// Copyright 2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo1() {} +void foo2() {} diff --git a/src/test/run-make-fulldeps/redundant-libs/main.rs b/src/test/run-make-fulldeps/redundant-libs/main.rs new file mode 100644 index 00000000000..796534d8116 --- /dev/null +++ b/src/test/run-make-fulldeps/redundant-libs/main.rs @@ -0,0 +1,30 @@ +// Copyright 2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// rustc will remove one of the two redundant references to foo below. Depending on which one gets +// removed, we'll get a linker error on SOME platforms (like Linux). On these platforms, when a +// library is referenced, the linker will only pull in the symbols needed _at that point in time_. +// If a later library depends on additional symbols from the library, they will not have been +// pulled in, and you'll get undefined symbols errors. +// +// So in this example, we need to ensure that rustc keeps the _later_ reference to foo, and not the +// former one. + +extern "C" { + fn bar(); + fn baz(); +} + +fn main() { + unsafe { + bar(); + baz(); + } +} |
