Rollup merge of #32946 - eddyb:issue-32783, r=dotdash

trans: always register an item's symbol, even if duplicated.

Fixes #32783 which was introduced by not always registering item symbols in #32742.
This commit is contained in:
Manish Goregaokar 2016-04-16 01:16:44 +05:30
commit 5bdbf8ef46
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
3 changed files with 40 additions and 32 deletions

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![crate_name="foreign_lib"]
#![feature(libc)]
pub mod rustrt {
@ -19,3 +20,29 @@ pub mod rustrt {
pub fn rust_get_test_int() -> libc::intptr_t;
}
}
pub mod rustrt2 {
extern crate libc;
extern {
pub fn rust_get_test_int() -> libc::intptr_t;
}
}
pub mod rustrt3 {
// Different type, but same ABI (on all supported platforms).
// Ensures that we don't ICE or trigger LLVM asserts when
// importing the same symbol under different types.
// See https://github.com/rust-lang/rust/issues/32740.
extern {
pub fn rust_get_test_int() -> *const u8;
}
}
pub fn local_uses() {
unsafe {
let x = rustrt::rust_get_test_int();
assert_eq!(x, rustrt2::rust_get_test_int());
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
}
}

View file

@ -8,41 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// calling pin_thread and that's having weird side-effects.
// aux-build:foreign_lib.rs
#![feature(libc)]
// Check that we can still call duplicated extern (imported) functions
// which were declared in another crate. See issues #32740 and #32783.
mod rustrt1 {
extern crate libc;
#[link(name = "rust_test_helpers")]
extern {
pub fn rust_get_test_int() -> libc::intptr_t;
}
}
mod rustrt2 {
extern crate libc;
extern {
pub fn rust_get_test_int() -> libc::intptr_t;
}
}
mod rustrt3 {
// Different type, but same ABI (on all supported platforms).
// Ensures that we don't ICE or trigger LLVM asserts when
// importing the same symbol under different types.
// See https://github.com/rust-lang/rust/issues/32740.
extern {
pub fn rust_get_test_int() -> *const u8;
}
}
extern crate foreign_lib;
pub fn main() {
unsafe {
let x = rustrt1::rust_get_test_int();
assert_eq!(x, rustrt2::rust_get_test_int());
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
let x = foreign_lib::rustrt::rust_get_test_int();
assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int());
assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int());
}
}