Add run-make-fulldeps test case

This commit is contained in:
Douglas Creager 2019-03-07 15:12:48 -05:00 committed by Douglas Creager
parent c56f128338
commit c641a8c424
5 changed files with 82 additions and 0 deletions

View 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)

View 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() {
}

View 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();
}

View 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() {}

View 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();
}
}