Change:
fn run_rmake_v2_test(&self) { // For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe <del> // (`rmake.rs`) to run the actual tests. The support library is already built as a tool // dylib and is available under `build/$TARGET/stageN-tools-bin/librun_make_support.rlib`. </del> <ins> // (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust // library and is available under `build/$TARGET/stageN-tools-bin/librun_make_support.rlib`. </ins> // <del> // 1. We need to build the recipe `rmake.rs` and link in the support library. // 2. We need to run the recipe to build and run the tests. let cwd = env::current_dir().unwrap(); let src_root = self.config.src_base.parent().unwrap().parent().unwrap(); let src_root = cwd.join(&src_root); let build_root = self.config.build_base.parent().unwrap().parent().unwrap(); let build_root = cwd.join(&build_root); </del> <ins> // 1. We need to build the recipe `rmake.rs` as a binary and link in the `run_make_support` //    library. // 2. We need to run the recipe binary. // FIXME(jieyouxu): path examples // source_root="/home/gh-jieyouxu/rust" // src_root="/home/gh-jieyouxu/rust" // build_root="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu" // self.config.build_base="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/test/run-make" // support_lib_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps" // support_lib_deps_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/release/deps" // recipe_bin="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/test/run-make/a-b-a-linker-guard/a-b-a-linker-guard/rmake" // So we assume the rust-lang/rust project setup looks like (our `.` is the top-level // directory, irrelevant entries to our purposes omitted): // // ``` // .                               // <- `source_root` // ├── build/                      // <- `build_root` // ├── compiler/ // ├── library/ // ├── src/ // │  └── tools/ // │     └── run_make_support/ // └── tests //    └── run-make/ // ``` // `source_root` is the top-level directory containing the rust-lang/rust checkout. let source_root = self.config.find_rust_src_root().expect("could not determine rust source root"); debug!(?source_root); // `self.config.build_base` is actually the build base folder + "test" + test suite name, it // looks like `build/<host_tuplet>/test/run-make`. But we want `build/<host_tuplet>/`. Note // that the `build` directory does not need to be called `build`, nor does it need to be // under `source_root`, so we must compute it based off of `self.config.build_base`. debug!(?self.config.build_base); let build_root = self.config.build_base.parent().and_then(Path::parent).unwrap().to_path_buf(); debug!(?build_root); </ins> // We construct the following directory tree for each rmake.rs test: // ``` <del> // base_dir/ </del> <ins> // <base_dir>/ </ins> //     rmake.exe //     rmake_out/ // ``` <del> // having the executable separate from the output artifacts directory allows the recipes to // `remove_dir_all($TMPDIR)` without running into permission denied issues because // the executable is not under the `rmake_out/` directory. </del> <ins> // having the recipe executable separate from the output artifacts directory allows the // recipes to `remove_dir_all($TMPDIR)` without running into issues related trying to remove // a currently running executable because the recipe executable is not under the // `rmake_out/` directory. </ins> // // This setup intentionally diverges from legacy Makefile run-make tests. <del> let base_dir = cwd.join(self.output_base_name()); </del> <ins> let base_dir = self.output_base_name(); </ins> if base_dir.exists() { self.aggressive_rm_rf(&base_dir).unwrap(); }

Discussion:
I've noticed when trying to debug why certain PRs were failing that our setup in compiletest contains "dead" env vars and some other hacks that warrant revisiting for reliability and correctness. I should revise how tests are setup in compiletest.