@@ -175,7 +175,8 @@ impl TestCx<'_> {
175
175
fn run_rmake_v2_test ( & self ) {
176
176
// For `run-make` V2, we need to perform 2 steps to build and run a `run-make` V2 recipe
177
177
// (`rmake.rs`) to run the actual tests. The support library is already built as a tool rust
178
- // library and is available under `build/$TARGET/stageN-tools-bin/librun_make_support.rlib`.
178
+ // library and is available under
179
+ // `build/$TARGET/stage0-bootstrap-tools/$HOST/release/librun_make_support.rlib`.
179
180
//
180
181
// 1. We need to build the recipe `rmake.rs` as a binary and link in the `run_make_support`
181
182
// library.
@@ -249,25 +250,21 @@ impl TestCx<'_> {
249
250
//
250
251
// ```
251
252
// build/<target_triple>/
252
- // ├── stageN-tools-bin/
253
- // │ └── librun_make_support.rlib // <- support rlib itself
254
- // ├── stageN-tools/
255
- // │ ├── release/deps/ // <- deps of deps
256
- // │ └── <host_triple>/release/deps/ // <- deps
253
+ // ├── stage0-bootstrap-tools/
254
+ // │ ├── <host_triple>/release/librun_make_support.rlib // <- support rlib itself
255
+ // │ ├── <host_triple>/release/deps/ // <- deps
256
+ // │ └── release/deps/ // <- deps of deps
257
257
// ```
258
258
//
259
259
// FIXME(jieyouxu): there almost certainly is a better way to do this (specifically how the
260
- // support lib and its deps are organized, can't we copy them to the tools-bin dir as
261
- // well?), but this seems to work for now.
260
+ // support lib and its deps are organized), but this seems to work for now.
262
261
263
- let stage_number = self . config . stage ;
262
+ let tools_bin = build_root. join ( "stage0-bootstrap-tools" ) ;
263
+ let support_host_path = tools_bin. join ( & self . config . host ) . join ( "release" ) ;
264
+ let support_lib_path = support_host_path. join ( "librun_make_support.rlib" ) ;
264
265
265
- let stage_tools_bin = build_root. join ( format ! ( "stage{stage_number}-tools-bin" ) ) ;
266
- let support_lib_path = stage_tools_bin. join ( "librun_make_support.rlib" ) ;
267
-
268
- let stage_tools = build_root. join ( format ! ( "stage{stage_number}-tools" ) ) ;
269
- let support_lib_deps = stage_tools. join ( & self . config . host ) . join ( "release" ) . join ( "deps" ) ;
270
- let support_lib_deps_deps = stage_tools. join ( "release" ) . join ( "deps" ) ;
266
+ let support_lib_deps = support_host_path. join ( "deps" ) ;
267
+ let support_lib_deps_deps = tools_bin. join ( "release" ) . join ( "deps" ) ;
271
268
272
269
// To compile the recipe with rustc, we need to provide suitable dynamic library search
273
270
// paths to rustc. This includes both:
@@ -278,12 +275,6 @@ impl TestCx<'_> {
278
275
let base_dylib_search_paths =
279
276
Vec :: from_iter ( env:: split_paths ( & env:: var ( dylib_env_var ( ) ) . unwrap ( ) ) ) ;
280
277
281
- let host_dylib_search_paths = {
282
- let mut paths = vec ! [ self . config. compile_lib_path. clone( ) ] ;
283
- paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
284
- paths
285
- } ;
286
-
287
278
// Calculate the paths of the recipe binary. As previously discussed, this is placed at
288
279
// `<base_dir>/<bin_name>` with `bin_name` being `rmake` or `rmake.exe` depending on
289
280
// platform.
@@ -293,7 +284,13 @@ impl TestCx<'_> {
293
284
p
294
285
} ;
295
286
296
- let mut rustc = Command :: new ( & self . config . rustc_path ) ;
287
+ // run-make-support and run-make tests are compiled using the bootstrap compiler
288
+ let bootstrap_rustc = {
289
+ let mut p = build_root. join ( "stage0" ) . join ( "bin" ) . join ( "rustc" ) ;
290
+ p. set_extension ( env:: consts:: EXE_EXTENSION ) ;
291
+ p
292
+ } ;
293
+ let mut rustc = Command :: new ( bootstrap_rustc) ;
297
294
rustc
298
295
. arg ( "-o" )
299
296
. arg ( & recipe_bin)
@@ -307,34 +304,14 @@ impl TestCx<'_> {
307
304
. arg ( format ! ( "run_make_support={}" , & support_lib_path. to_string_lossy( ) ) )
308
305
. arg ( "--edition=2021" )
309
306
. arg ( & self . testpaths . file . join ( "rmake.rs" ) )
310
- . arg ( "-Cprefer-dynamic" )
311
- // Provide necessary library search paths for rustc.
312
- . env ( dylib_env_var ( ) , & env:: join_paths ( host_dylib_search_paths) . unwrap ( ) ) ;
307
+ . arg ( "-Cprefer-dynamic" ) ;
313
308
314
309
// In test code we want to be very pedantic about values being silently discarded that are
315
310
// annotated with `#[must_use]`.
316
311
rustc. arg ( "-Dunused_must_use" ) ;
317
312
318
- // > `cg_clif` uses `COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0` for running the rustc
319
- // > test suite. With the introduction of rmake.rs this broke. `librun_make_support.rlib` is
320
- // > compiled using the bootstrap rustc wrapper which sets `--sysroot
321
- // > build/aarch64-unknown-linux-gnu/stage0-sysroot`, but then compiletest will compile
322
- // > `rmake.rs` using the sysroot of the bootstrap compiler causing it to not find the
323
- // > `libstd.rlib` against which `librun_make_support.rlib` is compiled.
324
- //
325
- // The gist here is that we have to pass the proper stage0 sysroot if we want
326
- //
327
- // ```
328
- // $ COMPILETEST_FORCE_STAGE0=1 ./x test run-make --stage 0
329
- // ```
330
- //
331
- // to work correctly.
332
- //
333
- // See <https://github.com/rust-lang/rust/pull/122248> for more background.
334
- let stage0_sysroot = build_root. join ( "stage0-sysroot" ) ;
335
- if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
336
- rustc. arg ( "--sysroot" ) . arg ( & stage0_sysroot) ;
337
- }
313
+ // TODO: test COMPILETEST_FORCE_STAGE0=1 ./x test tests/run-make --stage 0
314
+ // TODO: test ./x test tests/run-make
338
315
339
316
// Now run rustc to build the recipe.
340
317
let res = self . run_command_to_procres ( & mut rustc) ;
@@ -345,35 +322,22 @@ impl TestCx<'_> {
345
322
// To actually run the recipe, we have to provide the recipe with a bunch of information
346
323
// provided through env vars.
347
324
348
- // Compute stage-specific standard library paths.
349
- let stage_std_path = build_root. join ( format ! ( "stage{stage_number}" ) ) . join ( "lib" ) ;
350
-
351
325
// Compute dynamic library search paths for recipes.
326
+ // These dylib directories are needed to **execute the recipe**.
352
327
let recipe_dylib_search_paths = {
353
328
let mut paths = base_dylib_search_paths. clone ( ) ;
354
-
355
- // For stage 0, we need to explicitly include the stage0-sysroot libstd dylib.
356
- // See <https://github.com/rust-lang/rust/issues/135373>.
357
- if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
358
- paths. push (
359
- stage0_sysroot. join ( "lib" ) . join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ,
360
- ) ;
361
- }
362
-
363
- paths. push ( support_lib_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
364
- paths. push ( stage_std_path. join ( "rustlib" ) . join ( & self . config . host ) . join ( "lib" ) ) ;
365
- paths
366
- } ;
367
-
368
- // Compute runtime library search paths for recipes. This is target-specific.
369
- let target_runtime_dylib_search_paths = {
370
- let mut paths = vec ! [ rmake_out_dir. clone( ) ] ;
371
- paths. extend ( base_dylib_search_paths. iter ( ) . cloned ( ) ) ;
329
+ // This is the bootstrap stdlib required to run the rmake recipe itself
330
+ paths. push (
331
+ build_root
332
+ . join ( "stage0" )
333
+ . join ( "lib" )
334
+ . join ( "rustlib" )
335
+ . join ( & self . config . host )
336
+ . join ( "lib" ) ,
337
+ ) ;
372
338
paths
373
339
} ;
374
340
375
- // FIXME(jieyouxu): please rename `TARGET_RPATH_ENV`, `HOST_RPATH_DIR` and
376
- // `TARGET_RPATH_DIR`, it is **extremely** confusing!
377
341
let mut cmd = Command :: new ( & recipe_bin) ;
378
342
cmd. current_dir ( & rmake_out_dir)
379
343
. stdout ( Stdio :: piped ( ) )
@@ -382,9 +346,14 @@ impl TestCx<'_> {
382
346
// example, this could be `LD_LIBRARY_PATH` on some linux distros but `PATH` on Windows.
383
347
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
384
348
// Provide the dylib search paths.
349
+ // This is required to run the **recipe** itself.
385
350
. env ( dylib_env_var ( ) , & env:: join_paths ( recipe_dylib_search_paths) . unwrap ( ) )
386
- // Provide runtime dylib search paths.
387
- . env ( "TARGET_RPATH_ENV" , & env:: join_paths ( target_runtime_dylib_search_paths) . unwrap ( ) )
351
+ // Provide the directory to libraries that are needed to run the *compiler* invoked
352
+ // by the recipe.
353
+ . env ( "HOST_RUSTC_DYLIB_PATH" , & self . config . compile_lib_path )
354
+ // Provide the directory to libraries that might be needed to run binaries created
355
+ // by a compiler invoked by the recipe.
356
+ . env ( "TARGET_EXE_DYLIB_PATH" , & self . config . run_lib_path )
388
357
// Provide the target.
389
358
. env ( "TARGET" , & self . config . target )
390
359
// Some tests unfortunately still need Python, so provide path to a Python interpreter.
@@ -396,13 +365,6 @@ impl TestCx<'_> {
396
365
. env ( "BUILD_ROOT" , & build_root)
397
366
// Provide path to stage-corresponding rustc.
398
367
. env ( "RUSTC" , & self . config . rustc_path )
399
- // Provide the directory to libraries that are needed to run the *compiler*. This is not
400
- // to be confused with `TARGET_RPATH_ENV` or `TARGET_RPATH_DIR`. This is needed if the
401
- // recipe wants to invoke rustc.
402
- . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
403
- // Provide the directory to libraries that might be needed to run compiled binaries
404
- // (further compiled by the recipe!).
405
- . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
406
368
// Provide which LLVM components are available (e.g. which LLVM components are provided
407
369
// through a specific CI runner).
408
370
. env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
0 commit comments