Rollup merge of #130642 - cuviper:run-make-cargo, r=jieyouxu

Pass the current cargo to `run-make` tests

A couple tests were using `BOOTSTRAP_CARGO` with `-Zbuild-std`, but that
stage0 cargo might not always be in sync with in-tree changes. In
particular, those tests started failing on the beta branch because the
older cargo couldn't find the library `Cargo.lock`, and then couldn't
build the latest version of `compiler_builtins` that had nightly changes.

Fixes #130634
r? `@saethlin`
This commit is contained in:
Matthias Krüger 2024-09-21 07:22:48 +02:00 committed by GitHub
commit 43366285f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 24 additions and 5 deletions

View File

@ -1733,6 +1733,11 @@ fn run(self, builder: &Builder<'_>) {
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js"); let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
if mode == "run-make" {
let cargo = builder.ensure(tool::Cargo { compiler, target: compiler.host });
cmd.arg("--cargo-path").arg(cargo);
}
// Avoid depending on rustdoc when we don't need it. // Avoid depending on rustdoc when we don't need it.
if mode == "rustdoc" if mode == "rustdoc"
|| mode == "run-make" || mode == "run-make"

View File

@ -183,6 +183,9 @@ pub struct Config {
/// The rustc executable. /// The rustc executable.
pub rustc_path: PathBuf, pub rustc_path: PathBuf,
/// The cargo executable.
pub cargo_path: Option<PathBuf>,
/// The rustdoc executable. /// The rustdoc executable.
pub rustdoc_path: Option<PathBuf>, pub rustdoc_path: Option<PathBuf>,

View File

@ -47,6 +47,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH") opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH") .reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH") .reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
.optopt("", "cargo-path", "path to cargo to use for compiling", "PATH")
.optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH") .optopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
.optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH") .optopt("", "coverage-dump-path", "path to coverage-dump to use in tests", "PATH")
.reqopt("", "python", "path to python to use for doc tests", "PATH") .reqopt("", "python", "path to python to use for doc tests", "PATH")
@ -260,6 +261,7 @@ fn make_absolute(path: PathBuf) -> PathBuf {
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")), compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")), run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
rustc_path: opt_path(matches, "rustc-path"), rustc_path: opt_path(matches, "rustc-path"),
cargo_path: matches.opt_str("cargo-path").map(PathBuf::from),
rustdoc_path: matches.opt_str("rustdoc-path").map(PathBuf::from), rustdoc_path: matches.opt_str("rustdoc-path").map(PathBuf::from),
coverage_dump_path: matches.opt_str("coverage-dump-path").map(PathBuf::from), coverage_dump_path: matches.opt_str("coverage-dump-path").map(PathBuf::from),
python: matches.opt_str("python").unwrap(), python: matches.opt_str("python").unwrap(),
@ -364,6 +366,7 @@ pub fn log_config(config: &Config) {
logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path)); logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
logv(c, format!("run_lib_path: {:?}", config.run_lib_path)); logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
logv(c, format!("rustc_path: {:?}", config.rustc_path.display())); logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
logv(c, format!("cargo_path: {:?}", config.cargo_path));
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path)); logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
logv(c, format!("src_base: {:?}", config.src_base.display())); logv(c, format!("src_base: {:?}", config.src_base.display()));
logv(c, format!("build_base: {:?}", config.build_base.display())); logv(c, format!("build_base: {:?}", config.build_base.display()));

View File

@ -61,6 +61,10 @@ fn run_rmake_legacy_test(&self) {
.env_remove("MFLAGS") .env_remove("MFLAGS")
.env_remove("CARGO_MAKEFLAGS"); .env_remove("CARGO_MAKEFLAGS");
if let Some(ref cargo) = self.config.cargo_path {
cmd.env("CARGO", cwd.join(cargo));
}
if let Some(ref rustdoc) = self.config.rustdoc_path { if let Some(ref rustdoc) = self.config.rustdoc_path {
cmd.env("RUSTDOC", cwd.join(rustdoc)); cmd.env("RUSTDOC", cwd.join(rustdoc));
} }
@ -409,6 +413,10 @@ fn run_rmake_v2_test(&self) {
// through a specific CI runner). // through a specific CI runner).
.env("LLVM_COMPONENTS", &self.config.llvm_components); .env("LLVM_COMPONENTS", &self.config.llvm_components);
if let Some(ref cargo) = self.config.cargo_path {
cmd.env("CARGO", source_root.join(cargo));
}
if let Some(ref rustdoc) = self.config.rustdoc_path { if let Some(ref rustdoc) = self.config.rustdoc_path {
cmd.env("RUSTDOC", source_root.join(rustdoc)); cmd.env("RUSTDOC", source_root.join(rustdoc));
} }

View File

@ -33,8 +33,8 @@ fn main() {
let path = env_var("PATH"); let path = env_var("PATH");
let rustc = env_var("RUSTC"); let rustc = env_var("RUSTC");
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO"); let cargo = env_var("CARGO");
let mut cmd = cmd(bootstrap_cargo); let mut cmd = cmd(cargo);
cmd.args(&[ cmd.args(&[
"build", "build",
"--manifest-path", "--manifest-path",

View File

@ -36,10 +36,10 @@ fn main() {
let path = env_var("PATH"); let path = env_var("PATH");
let rustc = env_var("RUSTC"); let rustc = env_var("RUSTC");
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO"); let cargo = env_var("CARGO");
// FIXME: extract bootstrap cargo invocations to a proper command // FIXME: extract cargo invocations to a proper command
// https://github.com/rust-lang/rust/issues/128734 // https://github.com/rust-lang/rust/issues/128734
let mut cmd = cmd(bootstrap_cargo); let mut cmd = cmd(cargo);
cmd.args(&[ cmd.args(&[
"build", "build",
"--manifest-path", "--manifest-path",