Skip to content

Commit f3297bc

Browse files
committed
compiletest/rmake: cleanup dylib search paths related calculations
1 parent 19c6311 commit f3297bc

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,13 +3585,18 @@ impl<'test> TestCx<'test> {
35853585
debug!(?support_lib_deps_deps);
35863586

35873587
// FIXME(jieyouxu): explain what the hecc we are doing here.
3588-
let orig_dylib_env_paths =
3588+
3589+
// This is the base dynamic library search paths that was made available to compiletest.
3590+
let base_dylib_search_paths =
35893591
Vec::from_iter(env::split_paths(&env::var(dylib_env_var()).unwrap()));
35903592

3591-
let mut host_dylib_env_paths = Vec::new();
3592-
host_dylib_env_paths.push(self.config.compile_lib_path.clone());
3593-
host_dylib_env_paths.extend(orig_dylib_env_paths.iter().cloned());
3594-
let host_dylib_env_paths = env::join_paths(host_dylib_env_paths).unwrap();
3593+
// We add in `self.config.compile_lib_path` which are the libraries needed to run the
3594+
// host compiler.
3595+
let host_dylib_search_paths = {
3596+
let mut paths = vec![self.config.compile_lib_path.clone()];
3597+
paths.extend(base_dylib_search_paths.iter().cloned());
3598+
paths
3599+
};
35953600

35963601
// Finally, we need to run the recipe binary to build and run the actual tests.
35973602
// FIXME(jieyouxu): use `std::env::consts::EXE_EXTENSION`.
@@ -3619,7 +3624,7 @@ impl<'test> TestCx<'test> {
36193624
.env("RUST_BUILD_STAGE", &self.config.stage_id)
36203625
.env("RUSTC", &self.config.rustc_path)
36213626
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
3622-
.env(dylib_env_var(), &host_dylib_env_paths)
3627+
.env(dylib_env_var(), &env::join_paths(host_dylib_search_paths).unwrap())
36233628
.env("HOST_RPATH_DIR", &self.config.compile_lib_path)
36243629
.env("TARGET_RPATH_DIR", &self.config.run_lib_path)
36253630
.env("LLVM_COMPONENTS", &self.config.llvm_components);
@@ -3650,16 +3655,19 @@ impl<'test> TestCx<'test> {
36503655
stage_std_path.push("lib");
36513656

36523657
// FIXME(jieyouxu): explain what the hecc we are doing here.
3653-
let mut dylib_env_paths = orig_dylib_env_paths.clone();
3654-
dylib_env_paths.push(support_lib_path.parent().unwrap().to_path_buf());
3655-
dylib_env_paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
3656-
let dylib_env_paths = env::join_paths(dylib_env_paths).unwrap();
3658+
let recipe_dylib_search_paths = {
3659+
let mut paths = base_dylib_search_paths.clone();
3660+
paths.push(support_lib_path.parent().unwrap().to_path_buf());
3661+
paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
3662+
paths
3663+
};
36573664

36583665
// FIXME(jieyouxu): explain what the hecc we are doing here.
3659-
let mut target_rpath_env_path = Vec::new();
3660-
target_rpath_env_path.push(&rmake_out_dir);
3661-
target_rpath_env_path.extend(&orig_dylib_env_paths);
3662-
let target_rpath_env_path = env::join_paths(target_rpath_env_path).unwrap();
3666+
let target_rpaths = {
3667+
let mut paths = vec![rmake_out_dir.clone()];
3668+
paths.extend(base_dylib_search_paths.iter().cloned());
3669+
paths
3670+
};
36633671

36643672
// FIXME(jieyouxu): explain what the hecc we are doing here.
36653673
// FIXME(jieyouxu): audit these env vars. some of them only makes sense for make, not rustc!
@@ -3668,8 +3676,8 @@ impl<'test> TestCx<'test> {
36683676
.stdout(Stdio::piped())
36693677
.stderr(Stdio::piped())
36703678
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
3671-
.env("TARGET_RPATH_ENV", &target_rpath_env_path)
3672-
.env(dylib_env_var(), &dylib_env_paths)
3679+
.env("TARGET_RPATH_ENV", &env::join_paths(target_rpaths).unwrap())
3680+
.env(dylib_env_var(), &env::join_paths(recipe_dylib_search_paths).unwrap())
36733681
.env("TARGET", &self.config.target)
36743682
.env("PYTHON", &self.config.python)
36753683
.env("SOURCE_ROOT", &source_root)

0 commit comments

Comments
 (0)