File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -178,16 +178,17 @@ impl<'cfg> Compilation<'cfg> {
178
178
search_path
179
179
} ;
180
180
181
- search_path. extend ( util:: dylib_path ( ) . into_iter ( ) ) ;
182
- if cfg ! ( target_os = "macos" ) {
181
+ let dylib_path = util:: dylib_path ( ) ;
182
+ let dylib_path_is_empty = dylib_path. is_empty ( ) ;
183
+ search_path. extend ( dylib_path. into_iter ( ) ) ;
184
+ if cfg ! ( target_os = "macos" ) && dylib_path_is_empty {
183
185
// These are the defaults when DYLD_FALLBACK_LIBRARY_PATH isn't
184
- // set. Since Cargo is explicitly setting the value, make sure the
185
- // defaults still work.
186
- if let Ok ( home) = env:: var ( "HOME" ) {
186
+ // set or set to an empty string . Since Cargo is explicitly setting
187
+ // the value, make sure the defaults still work.
188
+ if let Some ( home) = env:: var_os ( "HOME" ) {
187
189
search_path. push ( PathBuf :: from ( home) . join ( "lib" ) ) ;
188
190
}
189
191
search_path. push ( PathBuf :: from ( "/usr/local/lib" ) ) ;
190
- search_path. push ( PathBuf :: from ( "/lib" ) ) ;
191
192
search_path. push ( PathBuf :: from ( "/usr/lib" ) ) ;
192
193
}
193
194
let search_path = join_paths ( & search_path, util:: dylib_path_envvar ( ) ) ?;
Original file line number Diff line number Diff line change @@ -1223,6 +1223,13 @@ fn run_link_system_path_macos() {
1223
1223
)
1224
1224
. unwrap ( ) ;
1225
1225
p. root ( ) . rm_rf ( ) ;
1226
- p2. cargo ( "run" ) . run ( ) ;
1227
- p2. cargo ( "test" ) . run ( ) ;
1226
+ const VAR : & str = "DYLD_FALLBACK_LIBRARY_PATH" ;
1227
+ // Reset DYLD_FALLBACK_LIBRARY_PATH so that we don't inherit anything that
1228
+ // was set by the cargo that invoked the test.
1229
+ p2. cargo ( "run" ) . env_remove ( VAR ) . run ( ) ;
1230
+ p2. cargo ( "test" ) . env_remove ( VAR ) . run ( ) ;
1231
+ // Ensure this still works when DYLD_FALLBACK_LIBRARY_PATH has
1232
+ // a value set.
1233
+ p2. cargo ( "run" ) . env ( VAR , & libdir) . run ( ) ;
1234
+ p2. cargo ( "test" ) . env ( VAR , & libdir) . run ( ) ;
1228
1235
}
You can’t perform that action at this time.
0 commit comments