Skip to content

Commit 2736a5d

Browse files
committed
Pass --json=timings to rustc when --timings and -Zsection-timings is enabled
1 parent d721f0f commit 2736a5d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,12 @@ fn add_allow_features(build_runner: &BuildRunner<'_, '_>, cmd: &mut ProcessBuild
10951095
///
10961096
/// [`--error-format`]: https://doc.rust-lang.org/nightly/rustc/command-line-arguments.html#--error-format-control-how-errors-are-produced
10971097
fn add_error_format_and_color(build_runner: &BuildRunner<'_, '_>, cmd: &mut ProcessBuilder) {
1098+
let enable_timings = build_runner.bcx.gctx.cli_unstable().section_timings
1099+
&& !build_runner.bcx.build_config.timing_outputs.is_empty();
1100+
if enable_timings {
1101+
cmd.arg("-Zunstable-options");
1102+
}
1103+
10981104
cmd.arg("--error-format=json");
10991105
let mut json = String::from("--json=diagnostic-rendered-ansi,artifacts,future-incompat");
11001106

@@ -1104,6 +1110,11 @@ fn add_error_format_and_color(build_runner: &BuildRunner<'_, '_>, cmd: &mut Proc
11041110
}
11051111
_ => {}
11061112
}
1113+
1114+
if enable_timings {
1115+
json.push_str(",timings");
1116+
}
1117+
11071118
cmd.arg(json);
11081119

11091120
let gctx = build_runner.bcx.gctx;

0 commit comments

Comments
 (0)