]> git.lizzy.rs Git - rust.git/commitdiff
Use loader_path instead of executable_path for osx
authorAlex Crichton <alex@alexcrichton.com>
Tue, 5 Nov 2013 22:17:30 +0000 (14:17 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 5 Nov 2013 22:17:30 +0000 (14:17 -0800)
According to apple's documentation of rpath semantics, @executable_path means
that the path is relative the the *process executable*, not necessarily the
library in question. On the other hand, @loader_path is the path that points to
the library which contains the @loader_path reference. All of our rpath usage is
based off the library or executable, not just the executable. This means that on
OSX we should be using @loader_path instead of @executable_path to achieve the
same semantics as linux's $ORIGIN.

src/librustc/back/rpath.rs

index 3d6a8350795b35e3af767456e71f9e4d581d66c2..6f76b228d3e3ec300918950f77d37a424e005603 100644 (file)
@@ -118,7 +118,7 @@ pub fn get_rpath_relative_to_output(os: session::Os,
     let prefix = match os {
         session::OsAndroid | session::OsLinux | session::OsFreebsd
                           => "$ORIGIN",
-        session::OsMacos => "@executable_path",
+        session::OsMacos => "@loader_path",
         session::OsWin32 => unreachable!()
     };
 
@@ -241,7 +241,7 @@ fn test_rpath_relative() {
         let res = get_rpath_relative_to_output(o,
                                                &Path::new("bin/rustc"),
                                                &Path::new("lib/libstd.so"));
-        assert_eq!(res.as_slice(), "@executable_path/../lib");
+        assert_eq!(res.as_slice(), "@loader_path/../lib");
     }
 
     #[test]