Skip to content

Commit 8bfa560

Browse files
committed
compiletest/rmake: cleanup dylib search paths related calculations
1 parent 98441ba commit 8bfa560

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
@@ -3580,13 +3580,18 @@ impl<'test> TestCx<'test> {
35803580
debug!(?support_lib_deps_deps);
35813581

35823582
// FIXME(jieyouxu): explain what the hecc we are doing here.
3583-
let orig_dylib_env_paths =
3583+
3584+
// This is the base dynamic library search paths that was made available to compiletest.
3585+
let base_dylib_search_paths =
35843586
Vec::from_iter(env::split_paths(&env::var(dylib_env_var()).unwrap()));
35853587

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

35913596
// Finally, we need to run the recipe binary to build and run the actual tests.
35923597
// FIXME(jieyouxu): use `std::env::consts::EXE_EXTENSION`.
@@ -3614,7 +3619,7 @@ impl<'test> TestCx<'test> {
36143619
.env("RUST_BUILD_STAGE", &self.config.stage_id)
36153620
.env("RUSTC", &self.config.rustc_path)
36163621
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
3617-
.env(dylib_env_var(), &host_dylib_env_paths)
3622+
.env(dylib_env_var(), &env::join_paths(host_dylib_search_paths).unwrap())
36183623
.env("HOST_RPATH_DIR", &self.config.compile_lib_path)
36193624
.env("TARGET_RPATH_DIR", &self.config.run_lib_path)
36203625
.env("LLVM_COMPONENTS", &self.config.llvm_components);
@@ -3645,16 +3650,19 @@ impl<'test> TestCx<'test> {
36453650
stage_std_path.push("lib");
36463651

36473652
// FIXME(jieyouxu): explain what the hecc we are doing here.
3648-
let mut dylib_env_paths = orig_dylib_env_paths.clone();
3649-
dylib_env_paths.push(support_lib_path.parent().unwrap().to_path_buf());
3650-
dylib_env_paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
3651-
let dylib_env_paths = env::join_paths(dylib_env_paths).unwrap();
3653+
let recipe_dylib_search_paths = {
3654+
let mut paths = base_dylib_search_paths.clone();
3655+
paths.push(support_lib_path.parent().unwrap().to_path_buf());
3656+
paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
3657+
paths
3658+
};
36523659

36533660
// FIXME(jieyouxu): explain what the hecc we are doing here.
3654-
let mut target_rpath_env_path = Vec::new();
3655-
target_rpath_env_path.push(&rmake_out_dir);
3656-
target_rpath_env_path.extend(&orig_dylib_env_paths);
3657-
let target_rpath_env_path = env::join_paths(target_rpath_env_path).unwrap();
3661+
let target_rpaths = {
3662+
let mut paths = vec![rmake_out_dir.clone()];
3663+
paths.extend(base_dylib_search_paths.iter().cloned());
3664+
paths
3665+
};
36583666

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

0 commit comments

Comments
 (0)