Skip to content

Commit 2f340a4

Browse files
committed
rpath the path to the runtime
We don't currently rpath native libs, but we do know where rustrt is located and everything needs to link to it.
1 parent 3d5471f commit 2f340a4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/comp/back/rpath.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,30 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> [str] {
2020
let sysroot = sess.filesearch().sysroot();
2121
let output = out_filename;
2222
let libs = cstore::get_used_crate_files(sess.get_cstore());
23+
// We don't currently rpath native libraries, but we know
24+
// where rustrt is and we know every rust program needs it
25+
let libs = libs + [get_sysroot_absolute_rt_lib(sess)];
26+
2327
let target_triple = sess.get_opts().target_triple;
2428
let rpaths = get_rpaths(cwd, sysroot, output, libs, target_triple);
2529
rpaths_to_flags(rpaths);
26-
[] // FIXME: activate RPATH!
30+
[] // FIXME: Activate RPATH!
2731
}
2832

2933
#[cfg(target_os="win32")]
3034
fn get_rpath_flags(_sess: session::session, _out_filename: str) -> [str] {
3135
[]
3236
}
3337

38+
fn get_sysroot_absolute_rt_lib(sess: session::session) -> fs::path {
39+
let path = [sess.filesearch().sysroot()]
40+
+ filesearch::relative_target_lib_path(
41+
sess.get_opts().target_triple)
42+
+ [os::dylib_filename("rustrt")];
43+
check vec::is_not_empty(path);
44+
fs::connect_many(path)
45+
}
46+
3447
fn rpaths_to_flags(rpaths: [str]) -> [str] {
3548
vec::map({ |rpath| #fmt("-Wl,-rpath,%s",rpath)}, rpaths)
3649
}

0 commit comments

Comments
 (0)