@@ -17,22 +17,35 @@ use errors::{self, ErrorKind, Error};
17
17
use filetime:: FileTime ;
18
18
use json;
19
19
use header:: TestProps ;
20
- use procsrv;
21
20
use test:: TestPaths ;
22
21
use util:: logv;
23
22
23
+ use std:: collections:: HashMap ;
24
24
use std:: collections:: HashSet ;
25
25
use std:: env;
26
+ use std:: ffi:: OsString ;
26
27
use std:: fs:: { self , File , create_dir_all} ;
27
28
use std:: io:: prelude:: * ;
28
29
use std:: io:: { self , BufReader } ;
29
30
use std:: path:: { Path , PathBuf } ;
30
31
use std:: process:: { Command , Output , ExitStatus , Stdio } ;
31
32
use std:: str;
32
- use std:: collections:: HashMap ;
33
33
34
34
use extract_gdb_version;
35
35
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
+
36
49
pub fn run ( config : Config , testpaths : & TestPaths ) {
37
50
match & * config. target {
38
51
@@ -1318,7 +1331,18 @@ actual:\n\
1318
1331
. stderr ( Stdio :: piped ( ) )
1319
1332
. stdin ( Stdio :: piped ( ) ) ;
1320
1333
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) ;
1322
1346
1323
1347
let mut child = command. spawn ( ) . expect ( & format ! ( "failed to exec `{:?}`" , & command) ) ;
1324
1348
if let Some ( input) = input {
@@ -2077,7 +2101,7 @@ actual:\n\
2077
2101
. env ( "RUSTDOC" ,
2078
2102
cwd. join ( & self . config . rustdoc_path . as_ref ( ) . expect ( "--rustdoc-path passed" ) ) )
2079
2103
. env ( "TMPDIR" , & tmpdir)
2080
- . env ( "LD_LIB_PATH_ENVVAR" , procsrv :: dylib_env_var ( ) )
2104
+ . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
2081
2105
. env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
2082
2106
. env ( "TARGET_RPATH_DIR" , cwd. join ( & self . config . run_lib_path ) )
2083
2107
. env ( "LLVM_COMPONENTS" , & self . config . llvm_components )
0 commit comments