@@ -17,22 +17,35 @@ use errors::{self, ErrorKind, Error};
1717use filetime:: FileTime ;
1818use json;
1919use header:: TestProps ;
20- use procsrv;
2120use test:: TestPaths ;
2221use util:: logv;
2322
23+ use std:: collections:: HashMap ;
2424use std:: collections:: HashSet ;
2525use std:: env;
26+ use std:: ffi:: OsString ;
2627use std:: fs:: { self , File , create_dir_all} ;
2728use std:: io:: prelude:: * ;
2829use std:: io:: { self , BufReader } ;
2930use std:: path:: { Path , PathBuf } ;
3031use std:: process:: { Command , Output , ExitStatus , Stdio } ;
3132use std:: str;
32- use std:: collections:: HashMap ;
3333
3434use extract_gdb_version;
3535
36+ /// The name of the environment variable that holds dynamic library locations.
37+ pub fn dylib_env_var ( ) -> & ' static str {
38+ if cfg ! ( windows) {
39+ "PATH"
40+ } else if cfg ! ( target_os = "macos" ) {
41+ "DYLD_LIBRARY_PATH"
42+ } else if cfg ! ( target_os = "haiku" ) {
43+ "LIBRARY_PATH"
44+ } else {
45+ "LD_LIBRARY_PATH"
46+ }
47+ }
48+
3649pub fn run ( config : Config , testpaths : & TestPaths ) {
3750 match & * config. target {
3851
@@ -1318,7 +1331,18 @@ actual:\n\
13181331 . stderr ( Stdio :: piped ( ) )
13191332 . stdin ( Stdio :: piped ( ) ) ;
13201333
1321- procsrv:: add_target_env ( & mut command, lib_path, aux_path) ;
1334+ // Need to be sure to put both the lib_path and the aux path in the dylib
1335+ // search path for the child.
1336+ let mut path = env:: split_paths ( & env:: var_os ( dylib_env_var ( ) ) . unwrap_or ( OsString :: new ( ) ) )
1337+ . collect :: < Vec < _ > > ( ) ;
1338+ if let Some ( p) = aux_path {
1339+ path. insert ( 0 , PathBuf :: from ( p) )
1340+ }
1341+ path. insert ( 0 , PathBuf :: from ( lib_path) ) ;
1342+
1343+ // Add the new dylib search path var
1344+ let newpath = env:: join_paths ( & path) . unwrap ( ) ;
1345+ command. env ( dylib_env_var ( ) , newpath) ;
13221346
13231347 let mut child = command. spawn ( ) . expect ( & format ! ( "failed to exec `{:?}`" , & command) ) ;
13241348 if let Some ( input) = input {
@@ -2077,7 +2101,7 @@ actual:\n\
20772101 . env ( "RUSTDOC" ,
20782102 cwd. join ( & self . config . rustdoc_path . as_ref ( ) . expect ( "--rustdoc-path passed" ) ) )
20792103 . env ( "TMPDIR" , & tmpdir)
2080- . env ( "LD_LIB_PATH_ENVVAR" , procsrv :: dylib_env_var ( ) )
2104+ . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
20812105 . env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
20822106 . env ( "TARGET_RPATH_DIR" , cwd. join ( & self . config . run_lib_path ) )
20832107 . env ( "LLVM_COMPONENTS" , & self . config . llvm_components )
0 commit comments