Skip to content

Commit 1e09da3

Browse files
eddybalexcrichton
authored andcommitted
---
yaml --- r: 278271 b: refs/heads/beta c: ba43dba h: refs/heads/master i: 278269: 4d215e1 278267: f3a057a 278263: 7d641c6 278255: 8bc02cc 278239: 0920de7 278207: 07be575 278143: b2afe6c 278015: f12855c
1 parent 59e1bea commit 1e09da3

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 0ab80b651626666a6215fbeac23231f2fc04f97b
26+
refs/heads/beta: ba43dbade94203e0fd2cbd15b719522077d32f80
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/callee.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,19 @@ fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
584584
debug!("get_fn: not casting pointer!");
585585

586586
attributes::from_fn_attrs(ccx, attrs, llfn);
587-
if let Some(id) = local_item {
587+
if local_item.is_some() {
588588
// FIXME(eddyb) Doubt all extern fn should allow unwinding.
589589
attributes::unwind(llfn, true);
590-
ccx.item_symbols().borrow_mut().insert(id, sym);
591590
}
592591

593592
llfn
594593
};
595594

595+
// Always insert into item_symbols, in case this item is exported.
596+
if let Some(id) = local_item {
597+
ccx.item_symbols().borrow_mut().insert(id, sym);
598+
}
599+
596600
ccx.instances().borrow_mut().insert(instance, llfn);
597601

598602
immediate_rvalue(llfn, fn_ptr_ty)

branches/beta/src/test/auxiliary/foreign_lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![crate_name="foreign_lib"]
12+
1213
#![feature(libc)]
1314

1415
pub mod rustrt {
@@ -19,3 +20,29 @@ pub mod rustrt {
1920
pub fn rust_get_test_int() -> libc::intptr_t;
2021
}
2122
}
23+
24+
pub mod rustrt2 {
25+
extern crate libc;
26+
27+
extern {
28+
pub fn rust_get_test_int() -> libc::intptr_t;
29+
}
30+
}
31+
32+
pub mod rustrt3 {
33+
// Different type, but same ABI (on all supported platforms).
34+
// Ensures that we don't ICE or trigger LLVM asserts when
35+
// importing the same symbol under different types.
36+
// See https://github.com/rust-lang/rust/issues/32740.
37+
extern {
38+
pub fn rust_get_test_int() -> *const u8;
39+
}
40+
}
41+
42+
pub fn local_uses() {
43+
unsafe {
44+
let x = rustrt::rust_get_test_int();
45+
assert_eq!(x, rustrt2::rust_get_test_int());
46+
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
47+
}
48+
}

branches/beta/src/test/run-pass/foreign-dupe.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// calling pin_thread and that's having weird side-effects.
11+
// aux-build:foreign_lib.rs
1212

13-
// pretty-expanded FIXME #23616
13+
// Check that we can still call duplicated extern (imported) functions
14+
// which were declared in another crate. See issues #32740 and #32783.
1415

15-
#![feature(libc)]
16-
17-
mod rustrt1 {
18-
extern crate libc;
19-
20-
#[link(name = "rust_test_helpers")]
21-
extern {
22-
pub fn rust_get_test_int() -> libc::intptr_t;
23-
}
24-
}
25-
26-
mod rustrt2 {
27-
extern crate libc;
28-
29-
extern {
30-
pub fn rust_get_test_int() -> libc::intptr_t;
31-
}
32-
}
33-
34-
mod rustrt3 {
35-
// Different type, but same ABI (on all supported platforms).
36-
// Ensures that we don't ICE or trigger LLVM asserts when
37-
// importing the same symbol under different types.
38-
// See https://github.com/rust-lang/rust/issues/32740.
39-
extern {
40-
pub fn rust_get_test_int() -> *const u8;
41-
}
42-
}
16+
extern crate foreign_lib;
4317

4418
pub fn main() {
4519
unsafe {
46-
let x = rustrt1::rust_get_test_int();
47-
assert_eq!(x, rustrt2::rust_get_test_int());
48-
assert_eq!(x as *const _, rustrt3::rust_get_test_int());
20+
let x = foreign_lib::rustrt::rust_get_test_int();
21+
assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int());
22+
assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int());
4923
}
5024
}

0 commit comments

Comments
 (0)