Skip to content

Add support for -Ztimings to x.py #65088

Closed
@nnethercote

Description

@nnethercote
Contributor

Cargo's new experimental -Ztimings flag is really cool. See here for sample output. It would be great to add support for this to x.py. It would help a lot with #65031.

I tried and failed to get -Ztimings working with rustc, according to some instructions here. One complication is that rustc normally builds with a beta version of Cargo, but -Ztimings is nightly only.

@ehuss : what steps did you take to get the rustc measurements? Thanks!

Activity

added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Oct 4, 2019
ehuss

ehuss commented on Oct 7, 2019

@ehuss
Contributor

I didn't run it against rustc, that was Alex. You have to edit config.toml and set build.cargo to a nightly version of cargo (like from the .rustup directory, or build it yourself). Then edit the cargo function to add -Ztimings. It looks like someone has made a PR to make that read from an env.

nnethercote

nnethercote commented on Oct 7, 2019

@nnethercote
ContributorAuthor

You have to edit config.toml and set build.cargo to a nightly version of cargo

@alexcrichton: can you give the exact steps here? I tried to do this but failed. Thanks!

ehuss

ehuss commented on Oct 7, 2019

@ehuss
Contributor

What kind of error did you run into? Here's what my rust config.toml looks like (adjust for your setup):

[build]
cargo = "/Users/eric/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/cargo"

And here's what the diff might look like:

diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 5d586f0c461..ef01c18eaa0 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -776,7 +776,8 @@ impl<'a> Builder<'a> {
         cargo
             .env("CARGO_TARGET_DIR", out_dir)
             .arg(cmd)
-            .arg("-Zconfig-profile");
+            .arg("-Zconfig-profile")
+            .arg("-Ztimings");

         let profile_var = |name: &str| {
             let profile = if self.config.rust_optimize {

I have nightly 2019-10-02, which seems to work. Sometimes bootstrapping won't work on the latest cargo because the bootstrap code needs updating, but it seems to be working at this point in time.

alexcrichton

alexcrichton commented on Oct 7, 2019

@alexcrichton
Member

@nnethercote oh I didn't actually add support to ./x.py when I generated my graphs, I literally just did:

$ cd src/rustc
$ cargo +nightly build -Z timings

and then fixed any missing env vars that the crates reported. I would expect that @ehuss's patch would work as expected, although it may also require a temporary check for if stage != 0 somewhere

added a commit that references this issue on Oct 9, 2019

Rollup merge of rust-lang#65129 - andjo403:cargo_args, r=alexcrichton

8697fb3
added a commit that references this issue on Oct 10, 2019

Auto merge of #65129 - andjo403:cargo_args, r=alexcrichton

Zoxc

Zoxc commented on Dec 25, 2019

@Zoxc
Contributor

You can now do this with CARGOFLAGS=-Ztimings.

andjo403

andjo403 commented on Mar 7, 2020

@andjo403
Contributor

@nnethercote do you want more support then CARGOFLAGS_BOOTSTRAP=-Ztimings ./x.py build --stage 1 or can this be closed now?

nnethercote

nnethercote commented on Mar 7, 2020

@nnethercote
ContributorAuthor

I used CARGOFLAGS=-Ztimings ./x.py build for the first time yesterday and it worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Zoxc@ehuss@alexcrichton@andjo403@jonas-schievink

        Issue actions

          Add support for `-Ztimings` to `x.py` · Issue #65088 · rust-lang/rust