Skip to content

Commit 529b19f

Browse files
committed
auto merge of #13903 : alexcrichton/rust/issue-13890, r=thestinger
The logic of the custom realpath function in metadata::loader was incorrect, but the logic in util::fs was correct. Closes #13890
2 parents f072984 + f9c2d0e commit 529b19f

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

src/librustc/metadata/loader.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use syntax::codemap::Span;
2222
use syntax::diagnostic::SpanHandler;
2323
use syntax::crateid::CrateId;
2424
use syntax::attr::AttrMetaMethods;
25+
use util::fs;
2526

2627
use std::c_str::ToCStr;
2728
use std::cast;
@@ -107,18 +108,6 @@ impl CratePaths {
107108
}
108109
}
109110

110-
// FIXME(#11857) this should be a "real" realpath
111-
fn realpath(p: &Path) -> Path {
112-
use std::os;
113-
use std::io::fs;
114-
115-
let path = os::make_absolute(p);
116-
match fs::readlink(&path) {
117-
Ok(p) => p,
118-
Err(..) => path
119-
}
120-
}
121-
122111
impl<'a> Context<'a> {
123112
pub fn maybe_load_library_crate(&mut self) -> Option<Library> {
124113
self.find_library_crate()
@@ -209,7 +198,6 @@ impl<'a> Context<'a> {
209198
None => return FileDoesntMatch,
210199
Some(file) => file,
211200
};
212-
info!("file: {}", file);
213201
if file.starts_with(rlib_prefix) && file.ends_with(".rlib") {
214202
info!("rlib candidate: {}", path.display());
215203
match self.try_match(file, rlib_prefix, ".rlib") {
@@ -219,7 +207,7 @@ impl<'a> Context<'a> {
219207
(HashSet::new(), HashSet::new())
220208
});
221209
let (ref mut rlibs, _) = *slot;
222-
rlibs.insert(realpath(path));
210+
rlibs.insert(fs::realpath(path).unwrap());
223211
FileMatches
224212
}
225213
None => {
@@ -236,7 +224,7 @@ impl<'a> Context<'a> {
236224
(HashSet::new(), HashSet::new())
237225
});
238226
let (_, ref mut dylibs) = *slot;
239-
dylibs.insert(realpath(path));
227+
dylibs.insert(fs::realpath(path).unwrap());
240228
FileMatches
241229
}
242230
None => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-include ../tools.mk
2+
3+
ifdef IS_WINDOWS
4+
all:
5+
else
6+
7+
NAME := $(shell $(RUSTC) --crate-file-name foo.rs)
8+
9+
all:
10+
mkdir -p $(TMPDIR)/outdir
11+
$(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME)
12+
ln -nsf outdir/$(NAME) $(TMPDIR)
13+
RUST_LOG=rustc::metadata::loader $(RUSTC) bar.rs
14+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
extern crate foo;
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
#![crate_type = "rlib"]
12+
#![crate_id = "foo"]

0 commit comments

Comments
 (0)