diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 74a1c8c467802..ebe3ce69dabe9 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -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 { 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 => { diff --git a/src/test/run-make/libs-through-symlinks/Makefile b/src/test/run-make/libs-through-symlinks/Makefile new file mode 100644 index 0000000000000..d19e8f22c0547 --- /dev/null +++ b/src/test/run-make/libs-through-symlinks/Makefile @@ -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 diff --git a/src/test/run-make/libs-through-symlinks/bar.rs b/src/test/run-make/libs-through-symlinks/bar.rs new file mode 100644 index 0000000000000..6316cfa3bba08 --- /dev/null +++ b/src/test/run-make/libs-through-symlinks/bar.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make/libs-through-symlinks/foo.rs b/src/test/run-make/libs-through-symlinks/foo.rs new file mode 100644 index 0000000000000..6864076d18e27 --- /dev/null +++ b/src/test/run-make/libs-through-symlinks/foo.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_id = "foo"]