Kobzol / cargo-pgo

Cargo subcommand for optimizing Rust binaries/libraries with PGO and BOLT.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stream output of `cargo`

Kobzol opened this issue · comments

Currently, cargo-pgo runs cargo, gathers its output and then writes it to the output. However, it would be much nicer if we could instead stream the output of cargo interactively, so that the user can see it immediately and not just at the end.

Use-case: #5 (comment)

BTW - if possible, try to propagate color formatting as well. I guess cargo disables color automatically when it detects its output is redirected, so it might involve passing an option to cargo to override this.

When I do a cargo build after a cargo pgo it causes a full dependency rebuild.
I'm not sure if my "config.toml" rustflags are being honoured?
I have them set as ["-C", "target-cpu=native", "-Z", "tune-cpu=native"]

I did a RUSTFLAGS="-C target-cpu=native -Z tune-cpu=native" cargo pgo optimize and it did seem to produce a different binary, but still did a full dependency rebuild when running cargo build.

Will this change allow the verbose cargo output to be streamed as well? So I can see what flags are being set during the build.

Great tool by the way 👍

Rustflags from the config file should be honored, but cargo build will always do a rebuild AFAIK, because cargo pgo uses PGO flags (instrumentation/optimization) that will invalidate other builds. You would have to pass e.g. RUSTFLAGS="-Cprofile-generate" to avoid a rebuild, but then you'd just use PGO again.. :)

Yes, with the streaming change, verbose output is also streamed and printed:

$ cargo pgo build -- --verbose

I published version 0.2.2 with cargo output streaming.