@@ -173,7 +173,8 @@ impl TestCx<'_> {
173173 fn run_rmake_v2_test ( & self ) {
174174 // For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe
175175 // (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust
176- // library and is available under `build/$TARGET/stageN-tools-bin/librun_make_support.rlib`.
176+ // library and is available under
177+ // `build/$TARGET/stage0-bootstrap-tools/$HOST/release/librun_make_support.rlib`.
177178 //
178179 // 1. We need to build the recipe `rmake.rs` as a binary and link in the `run_make_support`
179180 // library.
@@ -229,25 +230,21 @@ impl TestCx<'_> {
229230 //
230231 // ```
231232 // build/<target_triple>/
232- // ├── stageN-tools-bin/
233- // │ └── librun_make_support.rlib // <- support rlib itself
234- // ├── stageN-tools/
235- // │ ├── release/deps/ // <- deps of deps
236- // │ └── <host_triple>/release/deps/ // <- deps
233+ // ├── stage0-bootstrap-tools/
234+ // │ ├── <host_triple>/release/librun_make_support.rlib // <- support rlib itself
235+ // │ ├── <host_triple>/release/deps/ // <- deps
236+ // │ └── release/deps/ // <- deps of deps
237237 // ```
238238 //
239239 // FIXME(jieyouxu): there almost certainly is a better way to do this (specifically how the
240- // support lib and its deps are organized, can't we copy them to the tools-bin dir as
241- // well?), but this seems to work for now.
240+ // support lib and its deps are organized), but this seems to work for now.
242241
243- let stage_number = self . config . stage ;
242+ let tools_bin = build_root. join ( "stage0-bootstrap-tools" ) ;
243+ let support_host_path = tools_bin. join ( & self . config . host ) . join ( "release" ) ;
244+ let support_lib_path = support_host_path. join ( "librun_make_support.rlib" ) ;
244245
245- let stage_tools_bin = build_root. join ( format ! ( "stage{stage_number}-tools-bin" ) ) ;
246- let support_lib_path = stage_tools_bin. join ( "librun_make_support.rlib" ) ;
247-
248- let stage_tools = build_root. join ( format ! ( "stage{stage_number}-tools" ) ) ;
249- let support_lib_deps = stage_tools. join ( & self . config . host ) . join ( "release" ) . join ( "deps" ) ;
250- let support_lib_deps_deps = stage_tools. join ( "release" ) . join ( "deps" ) ;
246+ let support_lib_deps = support_host_path. join ( "deps" ) ;
247+ let support_lib_deps_deps = tools_bin. join ( "release" ) . join ( "deps" ) ;
251248
252249 // To compile the recipe with rustc, we need to provide suitable dynamic library search
253250 // paths to rustc. This includes both:
@@ -258,12 +255,6 @@ impl TestCx<'_> {
258255 let base_dylib_search_paths =
259256 Vec :: from_iter ( env:: split_paths ( & env:: var ( dylib_env_var ( ) ) . unwrap ( ) ) ) ;
260257
261- let host_dylib_search_paths = {
262- let mut paths = vec ! [ self . config. compile_lib_path. clone( ) ] ;
263- paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
264- paths
265- } ;
266-
267258 // Calculate the paths of the recipe binary. As previously discussed, this is placed at
268259 // `<base_dir>/<bin_name>` with `bin_name` being `rmake` or `rmake.exe` depending on
269260 // platform.
@@ -273,7 +264,13 @@ impl TestCx<'_> {
273264 p
274265 } ;
275266
276- let mut rustc = Command :: new ( & self . config . rustc_path ) ;
267+ // run-make-support and run-make tests are compiled using the bootstrap compiler
268+ let bootstrap_rustc = {
269+ let mut p = build_root. join ( "stage0" ) . join ( "bin" ) . join ( "rustc" ) ;
270+ p. set_extension ( env:: consts:: EXE_EXTENSION ) ;
271+ p
272+ } ;
273+ let mut rustc = Command :: new ( bootstrap_rustc) ;
277274 rustc
278275 . arg ( "-o" )
279276 . arg ( & recipe_bin)
@@ -287,35 +284,12 @@ impl TestCx<'_> {
287284 . arg ( format ! ( "run_make_support={}" , & support_lib_path. to_string_lossy( ) ) )
288285 . arg ( "--edition=2021" )
289286 . arg ( & self . testpaths . file . join ( "rmake.rs" ) )
290- . arg ( "-Cprefer-dynamic" )
291- // Provide necessary library search paths for rustc.
292- . env ( dylib_env_var ( ) , & env:: join_paths ( host_dylib_search_paths) . unwrap ( ) ) ;
287+ . arg ( "-Cprefer-dynamic" ) ;
293288
294289 // In test code we want to be very pedantic about values being silently discarded that are
295290 // annotated with `#[must_use]`.
296291 rustc. arg ( "-Dunused_must_use" ) ;
297292
298- // > `cg_clif` uses `COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0` for running the rustc
299- // > test suite. With the introduction of rmake.rs this broke. `librun_make_support.rlib` is
300- // > compiled using the bootstrap rustc wrapper which sets `--sysroot
301- // > build/aarch64-unknown-linux-gnu/stage0-sysroot`, but then compiletest will compile
302- // > `rmake.rs` using the sysroot of the bootstrap compiler causing it to not find the
303- // > `libstd.rlib` against which `librun_make_support.rlib` is compiled.
304- //
305- // The gist here is that we have to pass the proper stage0 sysroot if we want
306- //
307- // ```
308- // $ COMPILETEST_FORCE_STAGE0=1 ./x test run-make --stage 0
309- // ```
310- //
311- // to work correctly.
312- //
313- // See <https://github.com/rust-lang/rust/pull/122248> for more background.
314- let stage0_sysroot = build_root. join ( "stage0-sysroot" ) ;
315- if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
316- rustc. arg ( "--sysroot" ) . arg ( & stage0_sysroot) ;
317- }
318-
319293 // Now run rustc to build the recipe.
320294 let res = self . run_command_to_procres ( & mut rustc) ;
321295 if !res. status . success ( ) {
@@ -325,35 +299,22 @@ impl TestCx<'_> {
325299 // To actually run the recipe, we have to provide the recipe with a bunch of information
326300 // provided through env vars.
327301
328- // Compute stage-specific standard library paths.
329- let stage_std_path = build_root. join ( format ! ( "stage{stage_number}" ) ) . join ( "lib" ) ;
330-
331302 // Compute dynamic library search paths for recipes.
303+ // These dylib directories are needed to **execute the recipe**.
332304 let recipe_dylib_search_paths = {
333305 let mut paths = base_dylib_search_paths. clone ( ) ;
334-
335- // For stage 0, we need to explicitly include the stage0-sysroot libstd dylib.
336- // See <https://github.com/rust-lang/rust/issues/135373>.
337- if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
338- paths. push (
339- stage0_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ,
340- ) ;
341- }
342-
343- paths. push ( support_lib_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
344- paths. push ( stage_std_path. join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ) ;
345- paths
346- } ;
347-
348- // Compute runtime library search paths for recipes. This is target-specific.
349- let target_runtime_dylib_search_paths = {
350- let mut paths = vec ! [ rmake_out_dir. clone( ) ] ;
351- paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
306+ // This is the bootstrap stdlib required to run the rmake recipe itself
307+ paths. push (
308+ build_root
309+ . join ( "stage0" )
310+ . join ( "lib" )
311+ . join ( "rustlib" )
312+ . join ( & self . config . host )
313+ . join ( "lib" ) ,
314+ ) ;
352315 paths
353316 } ;
354317
355- // FIXME(jieyouxu): please rename `TARGET_RPATH_ENV`, `HOST_RPATH_DIR` and
356- // `TARGET_RPATH_DIR`, it is **extremely** confusing!
357318 let mut cmd = Command :: new ( & recipe_bin) ;
358319 cmd. current_dir ( & rmake_out_dir)
359320 . stdout ( Stdio :: piped ( ) )
@@ -362,9 +323,14 @@ impl TestCx<'_> {
362323 // example, this could be `LD_LIBRARY_PATH` on some linux distros but `PATH` on Windows.
363324 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
364325 // Provide the dylib search paths.
326+ // This is required to run the **recipe** itself.
365327 . env ( dylib_env_var ( ) , & env:: join_paths ( recipe_dylib_search_paths) . unwrap ( ) )
366- // Provide runtime dylib search paths.
367- . env ( "TARGET_RPATH_ENV" , & env:: join_paths ( target_runtime_dylib_search_paths) . unwrap ( ) )
328+ // Provide the directory to libraries that are needed to run the *compiler* invoked
329+ // by the recipe.
330+ . env ( "HOST_RUSTC_DYLIB_PATH" , & self . config . compile_lib_path )
331+ // Provide the directory to libraries that might be needed to run binaries created
332+ // by a compiler invoked by the recipe.
333+ . env ( "TARGET_EXE_DYLIB_PATH" , & self . config . run_lib_path )
368334 // Provide the target.
369335 . env ( "TARGET" , & self . config . target )
370336 // Some tests unfortunately still need Python, so provide path to a Python interpreter.
@@ -375,13 +341,6 @@ impl TestCx<'_> {
375341 . env ( "BUILD_ROOT" , & build_root)
376342 // Provide path to stage-corresponding rustc.
377343 . env ( "RUSTC" , & self . config . rustc_path )
378- // Provide the directory to libraries that are needed to run the *compiler*. This is not
379- // to be confused with `TARGET_RPATH_ENV` or `TARGET_RPATH_DIR`. This is needed if the
380- // recipe wants to invoke rustc.
381- . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
382- // Provide the directory to libraries that might be needed to run compiled binaries
383- // (further compiled by the recipe!).
384- . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
385344 // Provide which LLVM components are available (e.g. which LLVM components are provided
386345 // through a specific CI runner).
387346 . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
0 commit comments