rustc: Swap link order of native libs/rust deps

This commit swaps the order of linking local native libraries and upstream
native libraries on the linker command line. Detail of bugs this can cause can
be found in #28595, and this change also invalidates the test case that was
added for #12446 which is now considered a bug because the downstream dependency
would need to declare that it depends on the native library somehow.

Closes #28595
This commit is contained in:
Alex Crichton 2015-09-23 09:23:31 -07:00
parent 1c788d0a9a
commit 9502df5798
9 changed files with 72 additions and 49 deletions

View file

@ -1,6 +0,0 @@
-include ../tools.mk
all: $(call NATIVE_STATICLIB,foo)
$(RUSTC) foo.rs
$(RUSTC) bar.rs
$(call RUN,bar)

View file

@ -1,2 +0,0 @@
// ignore-license
void some_c_symbol() {}

View file

@ -0,0 +1,6 @@
-include ../tools.mk
all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b)
$(RUSTC) a.rs
$(RUSTC) b.rs
$(call RUN,b)

View file

@ -0,0 +1,11 @@
// Copyright 2015 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 a(void) {}

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,10 +10,7 @@
#![crate_type = "rlib"]
#[link(name = "a", kind = "static")]
extern {
fn some_c_symbol();
}
pub fn foo() {
unsafe { some_c_symbol() }
pub fn a();
}

View file

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,11 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate foo;
extern void a(void);
#[link(name = "foo")]
extern {}
fn main() {
foo::foo();
void b(void) {
a();
}

View file

@ -0,0 +1,21 @@
// Copyright 2015 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 crate a;
#[link(name = "b", kind = "static")]
extern {
pub fn b();
}
fn main() {
unsafe { b(); }
}