Skip to content

Commit ab86fac

Browse files
committed
Don’t ICE if fs::canonicalise fails in meta-load
This might fail when --extern library is a symlink to an invalid location. Instead just pretend it doesn’t exist at all.
1 parent c78c099 commit ab86fac

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

src/librustc/metadata/loader.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,14 @@ impl<'a> Context<'a> {
429429
let slot = candidates.entry(hash_str)
430430
.or_insert_with(|| (HashMap::new(), HashMap::new()));
431431
let (ref mut rlibs, ref mut dylibs) = *slot;
432-
if rlib {
433-
rlibs.insert(fs::canonicalize(path).unwrap(), kind);
434-
} else {
435-
dylibs.insert(fs::canonicalize(path).unwrap(), kind);
436-
}
437-
438-
FileMatches
432+
fs::canonicalize(path).map(|p| {
433+
if rlib {
434+
rlibs.insert(p, kind);
435+
} else {
436+
dylibs.insert(p, kind);
437+
}
438+
FileMatches
439+
}).unwrap_or(FileDoesntMatch)
439440
});
440441
self.rejected_via_kind.extend(staticlibs.into_iter());
441442

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-include ../tools.mk
2+
3+
ifndef IS_WINDOWS
4+
all: time
5+
6+
time: libc
7+
mkdir -p out/time out/time/deps
8+
ln -sf out/libc/liblibc.rlib out/time/deps/
9+
$(RUSTC) in/time/lib.rs -Ldependency=out/time/deps/
10+
11+
libc:
12+
mkdir -p out/libc
13+
$(RUSTC) in/libc/lib.rs --crate-name=libc -o out/libc/liblibc.rlib
14+
else
15+
all:
16+
endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 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+
#![crate_type="rlib"]
11+
12+
pub fn something(){}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 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+
#![feature(libc)]
11+
extern crate libc;
12+
13+
fn main(){}

0 commit comments

Comments
 (0)