Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for -Ztimings to x.py #65088

Closed
nnethercote opened this issue Oct 4, 2019 · 7 comments
Closed

Add support for -Ztimings to x.py #65088

nnethercote opened this issue Oct 4, 2019 · 7 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nnethercote
Copy link
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!

@jonas-schievink jonas-schievink added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 4, 2019
@ehuss
Copy link
Contributor

ehuss commented Oct 7, 2019

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
Copy link
Contributor Author

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
Copy link
Contributor

ehuss commented Oct 7, 2019

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
Copy link
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

Centril added a commit to Centril/rust that referenced this issue Oct 9, 2019
make it possible to add args to cargo in x.py

eg. make it easier to test -Ztimings for rustc

cc rust-lang#65088
bors added a commit that referenced this issue Oct 10, 2019
make it possible to add args to cargo in x.py

eg. make it easier to test -Ztimings for rustc

cc #65088
@Zoxc
Copy link
Contributor

Zoxc commented Dec 25, 2019

You can now do this with CARGOFLAGS=-Ztimings.

@andjo403
Copy link
Contributor

andjo403 commented Mar 7, 2020

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

@nnethercote
Copy link
Contributor Author

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
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants