Skip to content

Commit 5cd6dbd

Browse files
committed
Always use an absolute path for the backup install prefix rpath
1 parent 04e89af commit 5cd6dbd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/comp/back/rpath.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn get_rpaths(os: session::os, cwd: fs::path, sysroot: fs::path,
7171
let abs_rpaths = get_absolute_rpaths(cwd, libs);
7272

7373
// And a final backup rpath to the global library location.
74-
let fallback_rpaths = [get_install_prefix_rpath(target_triple)];
74+
let fallback_rpaths = [get_install_prefix_rpath(cwd, target_triple)];
7575

7676
fn log_rpaths(desc: str, rpaths: [str]) {
7777
log #fmt("%s rpaths:", desc);
@@ -166,7 +166,7 @@ fn get_absolute(cwd: fs::path, lib: fs::path) -> fs::path {
166166
}
167167
}
168168

169-
fn get_install_prefix_rpath(target_triple: str) -> str {
169+
fn get_install_prefix_rpath(cwd: fs::path, target_triple: str) -> str {
170170
let install_prefix = #env("CFG_PREFIX");
171171

172172
if install_prefix == "" {
@@ -176,7 +176,7 @@ fn get_install_prefix_rpath(target_triple: str) -> str {
176176
let path = [install_prefix]
177177
+ filesearch::relative_target_lib_path(target_triple);
178178
check vec::is_not_empty(path);
179-
fs::connect_many(path)
179+
get_absolute(cwd, fs::connect_many(path))
180180
}
181181

182182
fn minimize_rpaths(rpaths: [str]) -> [str] {
@@ -219,8 +219,15 @@ mod test {
219219

220220
#[test]
221221
fn test_prefix_rpath() {
222-
let res = get_install_prefix_rpath("triple");
223-
assert res == #env("CFG_PREFIX") + "/lib/rustc/triple/lib";
222+
let res = get_install_prefix_rpath("/usr/lib", "triple");
223+
assert str::ends_with(res, #env("CFG_PREFIX")
224+
+ "/lib/rustc/triple/lib");
225+
}
226+
227+
#[test]
228+
fn test_prefix_rpath_abs() {
229+
let res = get_install_prefix_rpath("/usr/lib", "triple");
230+
assert str::starts_with(res, "/");
224231
}
225232

226233
#[test]

0 commit comments

Comments
 (0)