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

Report codegen timings for binary crates #10960

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,16 @@ fn build_base_args(

if unit.mode.is_check() {
cmd.arg("--emit=dep-info,metadata");
} else if !unit.requires_upstream_objects() {
} else {
// Always produce metadata files for rlib outputs. Metadata may be used
// in this session for a pipelined compilation, or it may be used in a
// future Cargo session as part of a pipelined compile.
// Also include metadata for outputs that need to be linked and thus
// can't be pipelined as this will cause rustc to report when codegen
// starts even when the crate type doesn't actually support metadata
// files. This allows measuring how long codegen takes, which will be
// included in the report produced if `--timings` is passed.
cmd.arg("--emit=dep-info,metadata,link");
} else {
cmd.arg("--emit=dep-info,link");
}

let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build())
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ fn test_profile() {
[RUNNING] `rustc --crate-name bar [..]crate-type lib[..]
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C linker-plugin-lto[..]
[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,link -C lto=thin [..]--test[..]
[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,metadata,link -C lto=thin [..]--test[..]
[FINISHED] [..]
[RUNNING] [..]
[DOCTEST] foo
Expand Down