1
Fork 0

rustc: Use the "real" realpath function

The logic of the custom realpath function in metadata::loader was incorrect, but
the logic in util::fs was correct.

Closes #13890
This commit is contained in:
Alex Crichton 2014-05-02 13:50:24 -07:00
parent b5d6b07370
commit f9c2d0ebfb
4 changed files with 42 additions and 15 deletions

View file

@ -22,6 +22,7 @@ use syntax::codemap::Span;
use syntax::diagnostic::SpanHandler;
use syntax::crateid::CrateId;
use syntax::attr::AttrMetaMethods;
use util::fs;
use std::c_str::ToCStr;
use std::cast;
@ -107,18 +108,6 @@ impl CratePaths {
}
}
// FIXME(#11857) this should be a "real" realpath
fn realpath(p: &Path) -> Path {
use std::os;
use std::io::fs;
let path = os::make_absolute(p);
match fs::readlink(&path) {
Ok(p) => p,
Err(..) => path
}
}
impl<'a> Context<'a> {
pub fn maybe_load_library_crate(&mut self) -> Option<Library> {
self.find_library_crate()
@ -209,7 +198,6 @@ impl<'a> Context<'a> {
None => return FileDoesntMatch,
Some(file) => file,
};
info!("file: {}", file);
if file.starts_with(rlib_prefix) && file.ends_with(".rlib") {
info!("rlib candidate: {}", path.display());
match self.try_match(file, rlib_prefix, ".rlib") {
@ -219,7 +207,7 @@ impl<'a> Context<'a> {
(HashSet::new(), HashSet::new())
});
let (ref mut rlibs, _) = *slot;
rlibs.insert(realpath(path));
rlibs.insert(fs::realpath(path).unwrap());
FileMatches
}
None => {
@ -236,7 +224,7 @@ impl<'a> Context<'a> {
(HashSet::new(), HashSet::new())
});
let (_, ref mut dylibs) = *slot;
dylibs.insert(realpath(path));
dylibs.insert(fs::realpath(path).unwrap());
FileMatches
}
None => {

View file

@ -0,0 +1,14 @@
-include ../tools.mk
ifdef IS_WINDOWS
all:
else
NAME := $(shell $(RUSTC) --crate-file-name foo.rs)
all:
mkdir -p $(TMPDIR)/outdir
$(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME)
ln -nsf outdir/$(NAME) $(TMPDIR)
RUST_LOG=rustc::metadata::loader $(RUSTC) bar.rs
endif

View file

@ -0,0 +1,13 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate foo;
fn main() {}

View file

@ -0,0 +1,12 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_type = "rlib"]
#![crate_id = "foo"]