diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 4b54b1f60088..e455c4ad23ce 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -12,9 +12,10 @@ use driver::session::Session; use metadata::cstore; use metadata::filesearch; +use util::fs; use collections::HashSet; -use std::{os, slice}; +use std::os; use syntax::abi; fn not_win32(os: abi::Os) -> bool { @@ -121,9 +122,9 @@ pub fn get_rpath_relative_to_output(os: abi::Os, abi::OsWin32 => unreachable!() }; - let mut lib = os::make_absolute(lib); + let mut lib = fs::realpath(&os::make_absolute(lib)).unwrap(); lib.pop(); - let mut output = os::make_absolute(output); + let mut output = fs::realpath(&os::make_absolute(output)).unwrap(); output.pop(); let relative = lib.path_relative_from(&output); let relative = relative.expect("could not create rpath relative to output"); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 7a531c5c128b..f4ea386a2eca 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -15,6 +15,8 @@ use std::os; use std::io::fs; use collections::HashSet; +use myfs = util::fs; + pub enum FileMatch { FileMatches, FileDoesntMatch } // A module for searching for libraries @@ -156,17 +158,10 @@ fn make_rustpkg_target_lib_path(sysroot: &Path, pub fn get_or_default_sysroot() -> Path { // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: Option) -> Option { - path.and_then(|mut path| - match fs::readlink(&path) { - Ok(canon) => { - if canon.is_absolute() { - Some(canon) - } else { - path.pop(); - Some(path.join(canon)) - } - }, - Err(..) => Some(path), + path.and_then(|path| + match myfs::realpath(&path) { + Ok(canon) => Some(canon), + Err(e) => fail!("failed to get realpath: {}", e), }) }