@@ -3440,14 +3440,42 @@ impl<'test> TestCx<'test> {
34403440 // library.
34413441 // 2. We need to run the recipe binary.
34423442
3443- // FIXME(jieyouxu): hm, cwd doesn't look right here?
3444- let cwd = env:: current_dir ( ) . unwrap ( ) ;
3445- // FIXME(jieyouxu): is there a better way to get `src_root`?
3446- let src_root = self . config . src_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
3447- let src_root = cwd. join ( & src_root) ;
3448- // FIXME(jieyouxu): is there a better way to get `build_root`?
3449- let build_root = self . config . build_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
3450- let build_root = cwd. join ( & build_root) ;
3443+ // FIXME(jieyouxu): path examples
3444+ // source_root="/home/gh-jieyouxu/rust"
3445+ // src_root="/home/gh-jieyouxu/rust"
3446+ // build_root="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu"
3447+ // self.config.build_base="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/test/run-make"
3448+ // support_lib_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps"
3449+ // support_lib_deps_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/release/deps"
3450+ // 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"
3451+
3452+ // So we assume the rust-lang/rust project setup looks like (our `.` is the top-level
3453+ // directory, irrelevant entries to our purposes omitted):
3454+ //
3455+ // ```
3456+ // . // <- `source_root`
3457+ // ├── build/ // <- `build_root`
3458+ // ├── compiler/
3459+ // ├── library/
3460+ // ├── src/
3461+ // │ └── tools/
3462+ // │ └── run_make_support/
3463+ // └── tests
3464+ // └── run-make/
3465+ // ```
3466+
3467+ // `source_root` is the top-level directory containing the rust-lang/rust checkout.
3468+ let source_root =
3469+ self . config . find_rust_src_root ( ) . expect ( "could not determine rust source root" ) ;
3470+ debug ! ( ?source_root) ;
3471+ // `self.config.build_base` is actually the build base folder + "test" + test suite name, it
3472+ // looks like `build/<host_tuplet>/test/run-make`. But we want `build/<host_tuplet>/`. Note
3473+ // that the `build` directory does not need to be called `build`, nor does it need to be
3474+ // under `source_root`, so we must compute it based off of `self.config.build_base`.
3475+ debug ! ( ?self . config. build_base) ;
3476+ let build_root =
3477+ self . config . build_base . parent ( ) . and_then ( Path :: parent) . unwrap ( ) . to_path_buf ( ) ;
3478+ debug ! ( ?build_root) ;
34513479
34523480 // We construct the following directory tree for each rmake.rs test:
34533481 // ```
@@ -3462,7 +3490,7 @@ impl<'test> TestCx<'test> {
34623490 //
34633491 // This setup intentionally diverges from legacy Makefile run-make tests.
34643492 // FIXME(jieyouxu): is there a better way to compute `base_dir`?
3465- let base_dir = cwd . join ( self . output_base_name ( ) ) ;
3493+ let base_dir = self . output_base_name ( ) ;
34663494 if base_dir. exists ( ) {
34673495 self . aggressive_rm_rf ( & base_dir) . unwrap ( ) ;
34683496 }
@@ -3532,7 +3560,7 @@ impl<'test> TestCx<'test> {
35323560 Vec :: from_iter ( env:: split_paths ( & env:: var ( dylib_env_var ( ) ) . unwrap ( ) ) ) ;
35333561
35343562 let mut host_dylib_env_paths = Vec :: new ( ) ;
3535- host_dylib_env_paths. push ( cwd . join ( & self . config . compile_lib_path ) ) ;
3563+ host_dylib_env_paths. push ( self . config . compile_lib_path . clone ( ) ) ;
35363564 host_dylib_env_paths. extend ( orig_dylib_env_paths. iter ( ) . cloned ( ) ) ;
35373565 let host_dylib_env_paths = env:: join_paths ( host_dylib_env_paths) . unwrap ( ) ;
35383566
@@ -3551,17 +3579,18 @@ impl<'test> TestCx<'test> {
35513579 . env ( "TARGET" , & self . config . target )
35523580 . env ( "PYTHON" , & self . config . python )
35533581 . env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3554- . env ( "RUSTC" , cwd . join ( & self . config . rustc_path ) )
3582+ . env ( "RUSTC" , & self . config . rustc_path )
35553583 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
35563584 . env ( dylib_env_var ( ) , & host_dylib_env_paths)
3557- . env ( "HOST_RPATH_DIR" , cwd . join ( & self . config . compile_lib_path ) )
3558- . env ( "TARGET_RPATH_DIR" , cwd . join ( & self . config . run_lib_path ) )
3585+ . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
3586+ . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
35593587 . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
35603588
35613589 // In test code we want to be very pedantic about values being silently discarded that are
35623590 // annotated with `#[must_use]`.
35633591 cmd. arg ( "-Dunused_must_use" ) ;
35643592
3593+ // FIXME(jieyouxu): explain this!
35653594 if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
35663595 let mut stage0_sysroot = build_root. clone ( ) ;
35673596 stage0_sysroot. push ( "stage0-sysroot" ) ;
@@ -3602,15 +3631,15 @@ impl<'test> TestCx<'test> {
36023631 . env ( dylib_env_var ( ) , & dylib_env_paths)
36033632 . env ( "TARGET" , & self . config . target )
36043633 . env ( "PYTHON" , & self . config . python )
3605- . env ( "SOURCE_ROOT" , & src_root )
3634+ . env ( "SOURCE_ROOT" , & source_root )
36063635 . env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3607- . env ( "RUSTC" , cwd . join ( & self . config . rustc_path ) )
3608- . env ( "HOST_RPATH_DIR" , cwd . join ( & self . config . compile_lib_path ) )
3609- . env ( "TARGET_RPATH_DIR" , cwd . join ( & self . config . run_lib_path ) )
3636+ . env ( "RUSTC" , & self . config . rustc_path )
3637+ . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
3638+ . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
36103639 . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
36113640
36123641 if let Some ( ref rustdoc) = self . config . rustdoc_path {
3613- cmd. env ( "RUSTDOC" , cwd . join ( rustdoc) ) ;
3642+ cmd. env ( "RUSTDOC" , source_root . join ( rustdoc) ) ;
36143643 }
36153644
36163645 if let Some ( ref node) = self . config . nodejs {
0 commit comments