Skip to content

Commit 243c0da

Browse files
committed
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.
1 parent 1c56652 commit 243c0da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn get_rpath_relative_to_output(os: session::Os,
118118
let prefix = match os {
119119
session::OsAndroid | session::OsLinux | session::OsFreebsd
120120
=> "$ORIGIN",
121-
session::OsMacos => "@executable_path",
121+
session::OsMacos => "@loader_path",
122122
session::OsWin32 => unreachable!()
123123
};
124124

@@ -241,7 +241,7 @@ mod test {
241241
let res = get_rpath_relative_to_output(o,
242242
&Path::new("bin/rustc"),
243243
&Path::new("lib/libstd.so"));
244-
assert_eq!(res.as_slice(), "@executable_path/../lib");
244+
assert_eq!(res.as_slice(), "@loader_path/../lib");
245245
}
246246
247247
#[test]

0 commit comments

Comments
 (0)