From 243c0dac8fe7e06125bad7b1f87a61794c8636f1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 5 Nov 2013 14:17:30 -0800 Subject: [PATCH] Use loader_path instead of executable_path for osx 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 3d6a8350795b3..6f76b228d3e3e 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -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 @@ mod test { 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]