Add run-make-fulldeps test case
This commit is contained in:
parent
c56f128338
commit
c641a8c424
5 changed files with 82 additions and 0 deletions
11
src/test/run-make-fulldeps/redundant-libs/Makefile
Normal file
11
src/test/run-make-fulldeps/redundant-libs/Makefile
Normal file
|
|
@ -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)
|
||||
12
src/test/run-make-fulldeps/redundant-libs/bar.c
Normal file
12
src/test/run-make-fulldeps/redundant-libs/bar.c
Normal file
|
|
@ -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() {
|
||||
}
|
||||
17
src/test/run-make-fulldeps/redundant-libs/baz.c
Normal file
17
src/test/run-make-fulldeps/redundant-libs/baz.c
Normal file
|
|
@ -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();
|
||||
}
|
||||
12
src/test/run-make-fulldeps/redundant-libs/foo.c
Normal file
12
src/test/run-make-fulldeps/redundant-libs/foo.c
Normal file
|
|
@ -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() {}
|
||||
30
src/test/run-make-fulldeps/redundant-libs/main.rs
Normal file
30
src/test/run-make-fulldeps/redundant-libs/main.rs
Normal file
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue