feat: new arg --cargo-config for passing --config to cargo#1913
feat: new arg --cargo-config for passing --config to cargo#1913Kobzol merged 2 commits intorust-lang:masterfrom weihanglo:cargo-config
--cargo-config for passing --config to cargo#1913Conversation
|
To integrate this with diff --git a/src/tools/opt-dist/src/training.rs b/src/tools/opt-dist/src/training.rs
index 67c850b196d..9e417b01573 100644
--- a/src/tools/opt-dist/src/training.rs
+++ b/src/tools/opt-dist/src/training.rs
@@ -16,7 +16,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",
@@ -41,7 +41,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.This approach has a strong assumption: if there is a We could consider other alternatives, such as providing a |
Kobzol
left a comment
There was a problem hiding this comment.
Left a few nits, otherwise LGTM.
Could you please also document this in collector/README.md? Thanks!
This is another step toward making opt-dist work in sandboxed environments. `--cargo-config` is added to the following subcommands: * `binary_stats compile` * `bench_runtime_local` * `bench_local` * `profile_local` The current 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. We can leverage [`cargo --config`][1] to specify additional Cargo's configuration. Training data then could build with correct vendored settings via the `--cargo-config` flag. [1]: https://doc.rust-lang.org/nightly/cargo/commands/cargo.html#option-cargo---config
|
Everything has been pluralized (except the CLI argument name) and simplified. Thank you for your prompt review! |
Kobzol
left a comment
There was a problem hiding this comment.
Thanks! We'll need to update the rustc-perf version in rust-lang/rust after this.
Will do that. Maybe after rust-lang/measureme#229? |
|
Sure, there are probably more changes in general that need to be made before the builds can be truly self-contained (licensing etc., we'll need to update the |
…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
…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
…onfig, r=Kobzol feat(opt-dist): new flag `--benchmark-cargo-config` This should be the last piece toward self-contained `opt-dist` (I believe). The flag propagates cargo configs to `rustc-perf --cargo-config`, which is particularly useful when the environment is air-gapped, and you want to use the default set of training crates vendored in the rustc-src tarball. 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
…onfig, r=Kobzol feat(opt-dist): new flag `--benchmark-cargo-config` This should be the last piece toward self-contained `opt-dist` (I believe). The flag propagates cargo configs to `rustc-perf --cargo-config`, which is particularly useful when the environment is air-gapped, and you want to use the default set of training crates vendored in the rustc-src tarball. 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
Rollup merge of rust-lang#125930 - weihanglo:opt-dist-respect-cargo-config, r=Kobzol feat(opt-dist): new flag `--benchmark-cargo-config` This should be the last piece toward self-contained `opt-dist` (I believe). The flag propagates cargo configs to `rustc-perf --cargo-config`, which is particularly useful when the environment is air-gapped, and you want to use the default set of training crates vendored in the rustc-src tarball. 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
This is another step toward making opt-dist work in sandboxed environments.
--cargo-configis added to the following subcommands:binary_stats compilebench_runtime_localbench_localprofile_localRationale
The current rustc-perf uses
tempfile::Tempdiras the workingdirectory 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.tomlbundledin the rustc-src tarball.
We can leverage
cargo --configto specify additional Cargo's configuration.Training data then could build with correct vendored settings via the
--cargo-configflag.See also
r? @Kobzol
(Sorry I haven't figure out how to add tests for this)