@@ -1366,6 +1366,7 @@ impl Default for Options {
1366
1366
real_rust_source_base_dir : None ,
1367
1367
edition : DEFAULT_EDITION ,
1368
1368
json_artifact_notifications : false ,
1369
+ json_section_timings : false ,
1369
1370
json_unused_externs : JsonUnusedExterns :: No ,
1370
1371
json_future_incompat : false ,
1371
1372
pretty : None ,
@@ -1880,6 +1881,9 @@ pub struct JsonConfig {
1880
1881
pub json_rendered : HumanReadableErrorType ,
1881
1882
pub json_color : ColorConfig ,
1882
1883
json_artifact_notifications : bool ,
1884
+ /// Output start and end timestamps of several high-level compilation sections
1885
+ /// (frontend, backend, linker).
1886
+ json_section_timings : bool ,
1883
1887
pub json_unused_externs : JsonUnusedExterns ,
1884
1888
json_future_incompat : bool ,
1885
1889
}
@@ -1921,6 +1925,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
1921
1925
let mut json_artifact_notifications = false ;
1922
1926
let mut json_unused_externs = JsonUnusedExterns :: No ;
1923
1927
let mut json_future_incompat = false ;
1928
+ let mut json_section_timings = false ;
1924
1929
for option in matches. opt_strs ( "json" ) {
1925
1930
// For now conservatively forbid `--color` with `--json` since `--json`
1926
1931
// won't actually be emitting any colors and anything colorized is
@@ -1937,6 +1942,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
1937
1942
}
1938
1943
"diagnostic-rendered-ansi" => json_color = ColorConfig :: Always ,
1939
1944
"artifacts" => json_artifact_notifications = true ,
1945
+ "timings" => json_section_timings = true ,
1940
1946
"unused-externs" => json_unused_externs = JsonUnusedExterns :: Loud ,
1941
1947
"unused-externs-silent" => json_unused_externs = JsonUnusedExterns :: Silent ,
1942
1948
"future-incompat" => json_future_incompat = true ,
@@ -1949,6 +1955,7 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
1949
1955
json_rendered,
1950
1956
json_color,
1951
1957
json_artifact_notifications,
1958
+ json_section_timings,
1952
1959
json_unused_externs,
1953
1960
json_future_incompat,
1954
1961
}
@@ -2476,6 +2483,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
2476
2483
json_rendered,
2477
2484
json_color,
2478
2485
json_artifact_notifications,
2486
+ json_section_timings,
2479
2487
json_unused_externs,
2480
2488
json_future_incompat,
2481
2489
} = parse_json ( early_dcx, matches) ;
@@ -2497,6 +2505,10 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
2497
2505
let mut unstable_opts = UnstableOptions :: build ( early_dcx, matches, & mut target_modifiers) ;
2498
2506
let ( lint_opts, describe_lints, lint_cap) = get_cmd_lint_options ( early_dcx, matches) ;
2499
2507
2508
+ if !unstable_opts. unstable_options && json_section_timings {
2509
+ early_dcx. early_fatal ( "--json=timings is unstable and requires using `-Zunstable-options`" ) ;
2510
+ }
2511
+
2500
2512
check_error_format_stability ( early_dcx, & unstable_opts, error_format) ;
2501
2513
2502
2514
let output_types = parse_output_types ( early_dcx, & unstable_opts, matches) ;
@@ -2774,6 +2786,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
2774
2786
real_rust_source_base_dir,
2775
2787
edition,
2776
2788
json_artifact_notifications,
2789
+ json_section_timings,
2777
2790
json_unused_externs,
2778
2791
json_future_incompat,
2779
2792
pretty,
0 commit comments