From 9f22d423213bfc37262c247db6651163d1275859 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 24 Jul 2026 15:07:20 -0400 Subject: [PATCH 1/4] test(run-make): find cargo artifacts recursively Cargo enables build-dir layout v2 by default on nightly (rust-lang/cargo PR 17258). Intermediate build artifacts no longer live in `///deps/` but in per-unit `build///out/` directories. --- src/tools/run-make-support/src/lib.rs | 3 ++- .../run-make-support/src/path_helpers.rs | 24 +++++++++++++++++++ .../run-make-cargo/compiler-builtins/rmake.rs | 24 ++++++++----------- .../panic-immediate-abort-codegen/rmake.rs | 22 +++++++---------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index a686b25c34322..d3c2115e745e0 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -84,7 +84,8 @@ pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc}; // Path-related helpers. pub use crate::path_helpers::{ build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix, - has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root, + has_suffix, not_contains, path, recursive_find_files, shallow_find_directories, + shallow_find_files, source_root, }; // Convenience helpers for running binaries and other commands. pub use crate::run::{cmd, run, run_fail, run_with_args}; diff --git a/src/tools/run-make-support/src/path_helpers.rs b/src/tools/run-make-support/src/path_helpers.rs index b766e50e523b0..6dd075ac31d90 100644 --- a/src/tools/run-make-support/src/path_helpers.rs +++ b/src/tools/run-make-support/src/path_helpers.rs @@ -59,6 +59,30 @@ pub fn shallow_find_files, F: Fn(&PathBuf) -> bool>( matching_files } +/// Browse the directory `path` recursively and return all files which respect the parameters +/// outlined by `closure`. +#[track_caller] +pub fn recursive_find_files, F: Fn(&PathBuf) -> bool>( + path: P, + filter: F, +) -> Vec { + let mut matching_files = Vec::new(); + let mut stack = vec![path.as_ref().to_path_buf()]; + while let Some(dir) = stack.pop() { + for entry in rfs::read_dir(dir) { + let entry = entry.expect("failed to read directory entry."); + let path = entry.path(); + + if path.is_dir() { + stack.push(path); + } else if path.is_file() && filter(&path) { + matching_files.push(path); + } + } + } + matching_files +} + /// Browse the directory `path` non-recursively and return all directories which respect the /// parameters outlined by `closure`. #[track_caller] diff --git a/tests/run-make-cargo/compiler-builtins/rmake.rs b/tests/run-make-cargo/compiler-builtins/rmake.rs index 10093db2258df..bf973317009e5 100644 --- a/tests/run-make-cargo/compiler-builtins/rmake.rs +++ b/tests/run-make-cargo/compiler-builtins/rmake.rs @@ -19,8 +19,8 @@ use std::collections::HashSet; use run_make_support::object::read::Object; use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget}; -use run_make_support::rfs::{read, read_dir}; -use run_make_support::{cargo, object, path, target}; +use run_make_support::rfs::read; +use run_make_support::{cargo, object, path, recursive_find_files, target}; fn main() { let target_dir = path("target"); @@ -44,18 +44,14 @@ fn main() { .env("LIB", std::env::var("LIB").unwrap_or_default()) .run(); - let rlibs_path = target_dir.join(target()).join("debug").join("deps"); - let compiler_builtins_rlib = read_dir(rlibs_path) - .find_map(|e| { - let path = e.unwrap().path(); - let file_name = path.file_name().unwrap().to_str().unwrap(); - if file_name.starts_with("libcompiler_builtins") && file_name.ends_with(".rlib") { - Some(path) - } else { - None - } - }) - .unwrap(); + // The rlib file is emitted as an intermediate build artifacts. + // Do not hardcode the path. + let mut rlibs = recursive_find_files(&target_dir.join(target()).join("debug"), |path| { + let file_name = path.file_name().unwrap().to_str().unwrap(); + file_name.starts_with("libcompiler_builtins") && file_name.ends_with(".rlib") + }); + assert_eq!(rlibs.len(), 1, "expected exactly one compiler_builtins rlib: {rlibs:?}"); + let compiler_builtins_rlib = rlibs.pop().unwrap(); // rlib files are archives, where the archive members each a CGU, and we also have one called // lib.rmeta which is the encoded metadata. Each of the CGUs is an object file. diff --git a/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs b/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs index d7a7a8bfd8c3b..53c07eb1525b8 100644 --- a/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs +++ b/tests/run-make-cargo/panic-immediate-abort-codegen/rmake.rs @@ -5,7 +5,7 @@ #![deny(warnings)] -use run_make_support::{cargo, llvm_filecheck, path, rfs, target}; +use run_make_support::{cargo, llvm_filecheck, path, recursive_find_files, target}; fn main() { let target_dir = path("target"); @@ -29,18 +29,14 @@ fn main() { .env("LIB", std::env::var("LIB").unwrap_or_default()) .run(); - let out_dir = target_dir.join(target()).join("release").join("deps"); - let ir_file = rfs::read_dir(out_dir) - .find_map(|e| { - let path = e.unwrap().path(); - let file_name = path.file_name().unwrap().to_str().unwrap(); - if file_name.starts_with("panic_scenarios") && file_name.ends_with(".ll") { - Some(path) - } else { - None - } - }) - .unwrap(); + // The .ll file is emitted as an intermediate build artifacts. + // Do not hardcode the path. + let mut ir_files = recursive_find_files(&target_dir.join(target()).join("release"), |path| { + let file_name = path.file_name().unwrap().to_str().unwrap(); + file_name.starts_with("panic_scenarios") && file_name.ends_with(".ll") + }); + assert_eq!(ir_files.len(), 1, "expected exactly one .ll file: {ir_files:?}"); + let ir_file = ir_files.pop().unwrap(); llvm_filecheck().patterns("lib.rs").input_file(ir_file).run(); } From 2516ec72dac60aa2dbb3b15966c1a41a4600fcbd Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 29 Jul 2026 16:39:53 -0400 Subject: [PATCH 2/4] cargotest: opt-out cargo build dir new layout temporarily `xsv` locates binaries relative to `current_exe()`, which assumes Cargo's legacy build-dir layout: https://triage.rust-lang.org/gha-logs/rust-lang/rust/90658568103 We should revisit and replace xsv to something else with similar portfolio --- src/tools/cargotest/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 5bbed35e2068b..e920d49eb2e44 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -201,6 +201,14 @@ fn run_cargo_test( command.args(filters); let status = command + // `xsv` locates binaries relative to `current_exe()` + // which assumes Cargo legacy build-dir layout. + // + // See failure logs: + // https://triage.rust-lang.org/gha-logs/rust-lang/rust/90658568103 + // + // FIXME(weihanglo): replace xsv to something else with similar portfolio. + .env("__CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT", "1") // Disable rust-lang/cargo's cross-compile tests .env("CFG_DISABLE_CROSS_TESTS", "1") // Relax #![deny(warnings)] in some crates From f246ac010e37bdd7201d485651878f3dbb4aa38e Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sat, 25 Jul 2026 12:38:14 -0400 Subject: [PATCH 3/4] Update rustc-perf submodule --- src/tools/rustc-perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustc-perf b/src/tools/rustc-perf index 0508bdcd37152..74ecbcdf88411 160000 --- a/src/tools/rustc-perf +++ b/src/tools/rustc-perf @@ -1 +1 @@ -Subproject commit 0508bdcd37152b28c39b6752828683cdd3f128b5 +Subproject commit 74ecbcdf88411937a6e39baf2779948565dfd388 From 84600e086027936c1878a29e1417d5ea3e2636cc Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 24 Jul 2026 13:52:52 -0400 Subject: [PATCH 4/4] Update cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 3efb1f477e99b..7c83d4cc0953b 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 3efb1f477e99b42974b982d939fd100303cdf7db +Subproject commit 7c83d4cc0953b81d823e47d640c64da9b8bd4fac