@@ -3583,13 +3583,18 @@ impl<'test> TestCx<'test> {
35833583 debug ! ( ?support_lib_deps_deps) ;
35843584
35853585 // FIXME(jieyouxu): explain what the hecc we are doing here.
3586- let orig_dylib_env_paths =
3586+
3587+ // This is the base dynamic library search paths that was made available to compiletest.
3588+ let base_dylib_search_paths =
35873589 Vec :: from_iter ( env:: split_paths ( & env:: var ( dylib_env_var ( ) ) . unwrap ( ) ) ) ;
35883590
3589- let mut host_dylib_env_paths = Vec :: new ( ) ;
3590- host_dylib_env_paths. push ( self . config . compile_lib_path . clone ( ) ) ;
3591- host_dylib_env_paths. extend ( orig_dylib_env_paths. iter ( ) . cloned ( ) ) ;
3592- let host_dylib_env_paths = env:: join_paths ( host_dylib_env_paths) . unwrap ( ) ;
3591+ // We add in `self.config.compile_lib_path` which are the libraries needed to run the
3592+ // host compiler.
3593+ let host_dylib_search_paths = {
3594+ let mut paths = vec ! [ self . config. compile_lib_path. clone( ) ] ;
3595+ paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
3596+ paths
3597+ } ;
35933598
35943599 // Finally, we need to run the recipe binary to build and run the actual tests.
35953600 // FIXME(jieyouxu): use `std::env::consts::EXE_EXTENSION`.
@@ -3617,7 +3622,7 @@ impl<'test> TestCx<'test> {
36173622 . env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
36183623 . env ( "RUSTC" , & self . config . rustc_path )
36193624 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
3620- . env ( dylib_env_var ( ) , & host_dylib_env_paths )
3625+ . env ( dylib_env_var ( ) , & env :: join_paths ( host_dylib_search_paths ) . unwrap ( ) )
36213626 . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
36223627 . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
36233628 . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
@@ -3648,16 +3653,19 @@ impl<'test> TestCx<'test> {
36483653 stage_std_path. push ( "lib" ) ;
36493654
36503655 // FIXME(jieyouxu): explain what the hecc we are doing here.
3651- let mut dylib_env_paths = orig_dylib_env_paths. clone ( ) ;
3652- dylib_env_paths. push ( support_lib_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
3653- dylib_env_paths. push ( stage_std_path. join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ) ;
3654- let dylib_env_paths = env:: join_paths ( dylib_env_paths) . unwrap ( ) ;
3656+ let recipe_dylib_search_paths = {
3657+ let mut paths = base_dylib_search_paths. clone ( ) ;
3658+ paths. push ( support_lib_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
3659+ paths. push ( stage_std_path. join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ) ;
3660+ paths
3661+ } ;
36553662
36563663 // FIXME(jieyouxu): explain what the hecc we are doing here.
3657- let mut target_rpath_env_path = Vec :: new ( ) ;
3658- target_rpath_env_path. push ( & rmake_out_dir) ;
3659- target_rpath_env_path. extend ( & orig_dylib_env_paths) ;
3660- let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
3664+ let target_rpaths = {
3665+ let mut paths = vec ! [ rmake_out_dir. clone( ) ] ;
3666+ paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
3667+ paths
3668+ } ;
36613669
36623670 // FIXME(jieyouxu): explain what the hecc we are doing here.
36633671 // FIXME(jieyouxu): audit these env vars. some of them only makes sense for make, not rustc!
@@ -3666,8 +3674,8 @@ impl<'test> TestCx<'test> {
36663674 . stdout ( Stdio :: piped ( ) )
36673675 . stderr ( Stdio :: piped ( ) )
36683676 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
3669- . env ( "TARGET_RPATH_ENV" , & target_rpath_env_path )
3670- . env ( dylib_env_var ( ) , & dylib_env_paths )
3677+ . env ( "TARGET_RPATH_ENV" , & env :: join_paths ( target_rpaths ) . unwrap ( ) )
3678+ . env ( dylib_env_var ( ) , & env :: join_paths ( recipe_dylib_search_paths ) . unwrap ( ) )
36713679 . env ( "TARGET" , & self . config . target )
36723680 . env ( "PYTHON" , & self . config . python )
36733681 . env ( "SOURCE_ROOT" , & source_root)
0 commit comments