about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-04-07 15:40:58 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-04-10 15:22:00 -0700
commitec996737fe5e3f0693f4e92a33a53c2c189f36ba (patch)
tree5f095684857aff6b12b89b1567f80b5b31552639
parent85299e360cda49d61b8d9a509319e19bc206c336 (diff)
downloadrust-ec996737fe5e3f0693f4e92a33a53c2c189f36ba.tar.gz
rust-ec996737fe5e3f0693f4e92a33a53c2c189f36ba.zip
rustc: Remove absolute rpaths
Concerns have been raised about using absolute rpaths in #11746, and this is the
first step towards not relying on rpaths at all. The only current use case for
an absolute rpath is when a non-installed rust builds an executable that then
moves from is built location. The relative rpath back to libstd and absolute
rpath to the installation directory still remain (CFG_PREFIX).

Closes #11746
Rebasing of #12754
-rw-r--r--mk/main.mk4
-rw-r--r--src/librustc/back/rpath.rs30
2 files changed, 1 insertions, 33 deletions
diff --git a/mk/main.mk b/mk/main.mk
index fa19a4b380e..f2bcdbd4bd5 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -358,7 +358,6 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
 endif
 endif
 
-ifdef CFG_DISABLE_RPATH
 ifeq ($$(OSTYPE_$(3)),apple-darwin)
   RPATH_VAR$(1)_T_$(2)_H_$(3) := \
       DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
@@ -366,9 +365,6 @@ else
   RPATH_VAR$(1)_T_$(2)_H_$(3) := \
       LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
 endif
-else
-    RPATH_VAR$(1)_T_$(2)_H_$(3) :=
-endif
 
 STAGE$(1)_T_$(2)_H_$(3) := 						\
 	$$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3))                            \
diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs
index c47f9893cd2..73ccc8871ca 100644
--- a/src/librustc/back/rpath.rs
+++ b/src/librustc/back/rpath.rs
@@ -87,10 +87,6 @@ fn get_rpaths(os: abi::Os,
     // crates they depend on.
     let rel_rpaths = get_rpaths_relative_to_output(os, output, libs);
 
-    // Make backup absolute paths to the libraries. Binaries can
-    // be moved as long as the crates they link against don't move.
-    let abs_rpaths = get_absolute_rpaths(libs);
-
     // And a final backup rpath to the global library location.
     let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple));
 
@@ -102,11 +98,9 @@ fn get_rpaths(os: abi::Os,
     }
 
     log_rpaths("relative", rel_rpaths.as_slice());
-    log_rpaths("absolute", abs_rpaths.as_slice());
     log_rpaths("fallback", fallback_rpaths.as_slice());
 
     let mut rpaths = rel_rpaths;
-    rpaths.push_all(abs_rpaths.as_slice());
     rpaths.push_all(fallback_rpaths.as_slice());
 
     // Remove duplicates
@@ -146,17 +140,6 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
     prefix+"/"+relative.as_str().expect("non-utf8 component in path")
 }
 
-fn get_absolute_rpaths(libs: &[Path]) -> Vec<~str> {
-    libs.iter().map(|a| get_absolute_rpath(a)).collect()
-}
-
-pub fn get_absolute_rpath(lib: &Path) -> ~str {
-    let mut p = os::make_absolute(lib);
-    p.pop();
-    // FIXME (#9639): This needs to handle non-utf8 paths
-    p.as_str().expect("non-utf8 component in rpath").to_owned()
-}
-
 pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> ~str {
     let install_prefix = env!("CFG_PREFIX");
 
@@ -183,7 +166,7 @@ pub fn minimize_rpaths(rpaths: &[~str]) -> Vec<~str> {
 mod test {
     use std::os;
 
-    use back::rpath::{get_absolute_rpath, get_install_prefix_rpath};
+    use back::rpath::get_install_prefix_rpath;
     use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
     use syntax::abi;
     use metadata::filesearch;
@@ -258,15 +241,4 @@ mod test {
                                                &Path::new("lib/libstd.so"));
         assert_eq!(res.as_slice(), "@loader_path/../lib");
     }
-
-    #[test]
-    fn test_get_absolute_rpath() {
-        let res = get_absolute_rpath(&Path::new("lib/libstd.so"));
-        let lib = os::make_absolute(&Path::new("lib"));
-        debug!("test_get_absolute_rpath: {} vs. {}",
-               res.to_str(), lib.display());
-
-        // FIXME (#9639): This needs to handle non-utf8 paths
-        assert_eq!(res.as_slice(), lib.as_str().expect("non-utf8 component in path"));
-    }
 }