Skip to content

Commit 2ba0a8a

Browse files
committed
auto merge of #11603 : alexcrichton/rust/issue-11591, r=brson
This prevents linker errors as found in #11591 Closes #11591
2 parents eb5ba4d + 351d0ff commit 2ba0a8a

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

src/librustc/middle/reachable.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,23 @@ pub fn find_reachable(tcx: ty::ctxt,
404404
let reachable_context = ReachableContext::new(tcx, method_map);
405405

406406
// Step 1: Seed the worklist with all nodes which were found to be public as
407-
// a result of the privacy pass
407+
// a result of the privacy pass along with all local lang items. If
408+
// other crates link to us, they're going to expect to be able to
409+
// use the lang items, so we need to be sure to mark them as
410+
// exported.
411+
let mut worklist = reachable_context.worklist.borrow_mut();
408412
for &id in exported_items.iter() {
409-
let mut worklist = reachable_context.worklist.borrow_mut();
410413
worklist.get().push(id);
411414
}
415+
for (_, item) in tcx.lang_items.items() {
416+
match *item {
417+
Some(did) if is_local(did) => {
418+
worklist.get().push(did.node);
419+
}
420+
_ => {}
421+
}
422+
}
423+
drop(worklist);
412424

413425
// Step 2: Mark all symbols that the symbols on the worklist touch.
414426
reachable_context.propagate();
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[no_std];
12+
13+
#[lang="fail_"]
14+
fn fail(_: *i8, _: *i8, _: uint) -> ! { loop {} }
15+
16+
#[no_mangle]
17+
pub extern "C" fn rust_stack_exhausted() {}

src/test/run-pass/lang-item-public.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:lang-item-public.rs
12+
// ignore-fast
13+
// ignore-android
14+
15+
#[no_std];
16+
17+
extern crate lang_lib = "lang-item-public";
18+
19+
#[cfg(target_os = "linux")]
20+
#[link(name = "c")]
21+
extern {}
22+
23+
#[cfg(target_os = "android")]
24+
#[link(name = "c")]
25+
extern {}
26+
27+
#[cfg(target_os = "freebsd")]
28+
#[link(name = "execinfo")]
29+
extern {}
30+
31+
#[cfg(target_os = "macos")]
32+
#[link(name = "System")]
33+
extern {}
34+
35+
#[start]
36+
fn main(_: int, _: **u8) -> int {
37+
1 % 1
38+
}

0 commit comments

Comments
 (0)