@@ -19,6 +19,7 @@ pub struct RPathConfig<'a> {
1919 pub out_filename : PathBuf ,
2020 pub is_like_osx : bool ,
2121 pub has_rpath : bool ,
22+ pub linker_is_gnu : bool ,
2223 pub get_install_prefix_lib_path : & ' a mut FnMut ( ) -> PathBuf ,
2324}
2425
@@ -36,6 +37,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec<String> {
3637 let libs = libs. into_iter ( ) . filter_map ( |( _, l) | l) . collect :: < Vec < _ > > ( ) ;
3738 let rpaths = get_rpaths ( config, & libs[ ..] ) ;
3839 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+
3946 flags
4047}
4148
@@ -228,6 +235,7 @@ mod tests {
228235 used_crates : Vec :: new ( ) ,
229236 has_rpath : true ,
230237 is_like_osx : true ,
238+ linker_is_gnu : false ,
231239 out_filename : PathBuf :: from ( "bin/rustc" ) ,
232240 get_install_prefix_lib_path : & mut || panic ! ( ) ,
233241 } ;
@@ -241,6 +249,7 @@ mod tests {
241249 get_install_prefix_lib_path : & mut || panic ! ( ) ,
242250 has_rpath : true ,
243251 is_like_osx : false ,
252+ linker_is_gnu : true ,
244253 } ;
245254 let res = get_rpath_relative_to_output ( config,
246255 Path :: new ( "lib/libstd.so" ) ) ;
0 commit comments