Skip to content

Commit ec4e11a

Browse files
committed
Auto merge of #125930 - weihanglo:opt-dist-respect-cargo-config, 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 #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> * <#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
2 parents 8768db9 + ff6aceb commit ec4e11a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/tools/opt-dist/src/training.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn init_compiler_benchmarks(
3636
// Run rustc-perf benchmarks
3737
// Benchmark using profile_local with eprintln, which essentially just means
3838
// don't actually benchmark -- just make sure we run rustc a bunch of times.
39-
cmd(&[
39+
let mut cmd = cmd(&[
4040
env.cargo_stage_0().as_str(),
4141
"run",
4242
"-p",
@@ -61,7 +61,16 @@ fn init_compiler_benchmarks(
6161
.env("RUST_LOG", "collector=debug")
6262
.env("RUSTC", env.rustc_stage_0().as_str())
6363
.env("RUSTC_BOOTSTRAP", "1")
64-
.workdir(&env.rustc_perf_dir())
64+
.workdir(&env.rustc_perf_dir());
65+
66+
// Respect `.cargo/config.toml` in the rustc source. This is useful when the
67+
// source is from a tarball and contains vendored source settings.
68+
let dot_cargo_config_toml = env.checkout_path().join(".cargo").join("config.toml");
69+
if dot_cargo_config_toml.is_file() {
70+
cmd = cmd.arg("--cargo-config").arg(dot_cargo_config_toml);
71+
}
72+
73+
cmd
6574
}
6675

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

0 commit comments

Comments
 (0)