@@ -19,6 +19,7 @@ pub struct RPathConfig<'a> {
19
19
pub out_filename : PathBuf ,
20
20
pub is_like_osx : bool ,
21
21
pub has_rpath : bool ,
22
+ pub linker_is_gnu : bool ,
22
23
pub get_install_prefix_lib_path : & ' a mut FnMut ( ) -> PathBuf ,
23
24
}
24
25
@@ -36,6 +37,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec<String> {
36
37
let libs = libs. into_iter ( ) . filter_map ( |( _, l) | l) . collect :: < Vec < _ > > ( ) ;
37
38
let rpaths = get_rpaths ( config, & libs[ ..] ) ;
38
39
flags. extend_from_slice ( & rpaths_to_flags ( & rpaths[ ..] ) ) ;
40
+
41
+ // Use DT_RUNPATH instead of DT_RPATH if available
42
+ if config. linker_is_gnu {
43
+ flags. push ( "-Wl,--enable-new-dtags" . to_string ( ) ) ;
44
+ }
45
+
39
46
flags
40
47
}
41
48
@@ -228,6 +235,7 @@ mod tests {
228
235
used_crates : Vec :: new ( ) ,
229
236
has_rpath : true ,
230
237
is_like_osx : true ,
238
+ linker_is_gnu : false ,
231
239
out_filename : PathBuf :: from ( "bin/rustc" ) ,
232
240
get_install_prefix_lib_path : & mut || panic ! ( ) ,
233
241
} ;
@@ -241,6 +249,7 @@ mod tests {
241
249
get_install_prefix_lib_path : & mut || panic ! ( ) ,
242
250
has_rpath : true ,
243
251
is_like_osx : false ,
252
+ linker_is_gnu : true ,
244
253
} ;
245
254
let res = get_rpath_relative_to_output ( config,
246
255
Path :: new ( "lib/libstd.so" ) ) ;
0 commit comments