Skip to content

Commit

Permalink
Auto merge of rust-lang#125930 - weihanglo:opt-dist-respect-cargo-con…
Browse files Browse the repository at this point in the history
…fig, r=<try>

feat(opt-dist): respect existing .cargo/config.toml

This should be the last piece toward self-contained `opt-dist` (I believe).

It fixes the issue described in rust-lang#125465

> * The current pinned rustc-perf uses `tempfile::Tempdir` as the working
  directory when collecting profiles from some of these packages.
  This "tmp" working directory usage make it impossible for Cargo to pick
  up the correct vendor sources setting in `.cargo/config.toml` bundled
  in the rustc-src tarball. [^1]
> [^1]: https://github.com/rust-lang/rustc-perf/blob/4f313add609f43e928e98132358e8426ed3969ae/collector/src/compile/benchmark/mod.rs#L164-L173

See also

* <rust-lang/rustc-perf#1913>
* <rust-lang#125465>
* https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/tempfile.20in.20rustc-perf.20make.20it.20hard.20to.20configure.20vendor

r​? Kobzol
  • Loading branch information
bors committed Jun 3, 2024
2 parents 8768db9 + 89fb909 commit 8c225b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/tools/opt-dist/src/training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn init_compiler_benchmarks(
// Run rustc-perf benchmarks
// Benchmark using profile_local with eprintln, which essentially just means
// don't actually benchmark -- just make sure we run rustc a bunch of times.
cmd(&[
let mut cmd = cmd(&[
env.cargo_stage_0().as_str(),
"run",
"-p",
Expand All @@ -61,7 +61,16 @@ fn init_compiler_benchmarks(
.env("RUST_LOG", "collector=debug")
.env("RUSTC", env.rustc_stage_0().as_str())
.env("RUSTC_BOOTSTRAP", "1")
.workdir(&env.rustc_perf_dir())
.workdir(&env.rustc_perf_dir());

// Respect `.cargo/config.toml` in the rustc source. This is useful when the
// source is from a tarball and contains vendored source settings.
let dot_cargo_config_toml = env.checkout_path().join(".cargo").join("config.toml");
if dot_cargo_config_toml.is_file() {
cmd.arg("--cargo-config").arg(dot_cargo_config_toml);
}

cmd
}

/// Describes which `llvm-profdata` binary should be used for merging PGO profiles.
Expand Down

0 comments on commit 8c225b2

Please sign in to comment.