@@ -28,6 +28,8 @@ use std::{env, fs, io, str};
28
28
use build_helper:: ci:: gha;
29
29
use build_helper:: exit;
30
30
use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
31
+ #[ cfg( feature = "tracing" ) ]
32
+ use tracing:: { debug, instrument, span, trace} ;
31
33
use utils:: build_stamp:: BuildStamp ;
32
34
use utils:: channel:: GitInfo ;
33
35
@@ -537,14 +539,25 @@ impl Build {
537
539
}
538
540
539
541
/// Executes the entire build, as configured by the flags and configuration.
542
+ #[ cfg_attr( feature = "tracing" , instrument( level = "debug" , name = "Build::build" , skip_all) ) ]
540
543
pub fn build ( & mut self ) {
544
+ #[ cfg( feature = "tracing" ) ]
545
+ trace ! ( "setting up job management" ) ;
541
546
unsafe {
542
547
crate :: utils:: job:: setup ( self ) ;
543
548
}
544
549
550
+ #[ cfg( feature = "tracing" ) ]
551
+ trace ! ( "downloading rustfmt early" ) ;
552
+
545
553
// Download rustfmt early so that it can be used in rust-analyzer configs.
546
554
let _ = & builder:: Builder :: new ( self ) . initial_rustfmt ( ) ;
547
555
556
+ #[ cfg( feature = "tracing" ) ]
557
+ let hardcoded_span =
558
+ span ! ( tracing:: Level :: DEBUG , "handling hardcoded subcommands (Format, Suggest, Perf)" )
559
+ . entered ( ) ;
560
+
548
561
// hardcoded subcommands
549
562
match & self . config . cmd {
550
563
Subcommand :: Format { check, all } => {
@@ -561,25 +574,50 @@ impl Build {
561
574
Subcommand :: Perf { .. } => {
562
575
return core:: build_steps:: perf:: perf ( & builder:: Builder :: new ( self ) ) ;
563
576
}
564
- _ => ( ) ,
577
+ _cmd => {
578
+ #[ cfg( feature = "tracing" ) ]
579
+ debug ! ( cmd = ?_cmd, "not a hardcoded subcommand; returning to normal handling" ) ;
580
+ }
565
581
}
566
582
583
+ #[ cfg( feature = "tracing" ) ]
584
+ drop ( hardcoded_span) ;
585
+ #[ cfg( feature = "tracing" ) ]
586
+ debug ! ( "handling subcommand normally" ) ;
587
+
567
588
if !self . config . dry_run ( ) {
589
+ #[ cfg( feature = "tracing" ) ]
590
+ let _real_run_span = span ! ( tracing:: Level :: DEBUG , "executing real run" ) . entered ( ) ;
591
+
568
592
{
593
+ #[ cfg( feature = "tracing" ) ]
594
+ let _sanity_check_span =
595
+ span ! ( tracing:: Level :: DEBUG , "(1) executing dry-run sanity-check" ) . entered ( ) ;
596
+
569
597
// We first do a dry-run. This is a sanity-check to ensure that
570
598
// steps don't do anything expensive in the dry-run.
571
599
self . config . dry_run = DryRun :: SelfCheck ;
572
600
let builder = builder:: Builder :: new ( self ) ;
573
601
builder. execute_cli ( ) ;
574
602
}
603
+
604
+ #[ cfg( feature = "tracing" ) ]
605
+ let _actual_run_span =
606
+ span ! ( tracing:: Level :: DEBUG , "(2) executing actual run" ) . entered ( ) ;
575
607
self . config . dry_run = DryRun :: Disabled ;
576
608
let builder = builder:: Builder :: new ( self ) ;
577
609
builder. execute_cli ( ) ;
578
610
} else {
611
+ #[ cfg( feature = "tracing" ) ]
612
+ let _dry_run_span = span ! ( tracing:: Level :: DEBUG , "executing dry run" ) . entered ( ) ;
613
+
579
614
let builder = builder:: Builder :: new ( self ) ;
580
615
builder. execute_cli ( ) ;
581
616
}
582
617
618
+ #[ cfg( feature = "tracing" ) ]
619
+ debug ! ( "checking for postponed test failures from `test --no-fail-fast`" ) ;
620
+
583
621
// Check for postponed failures from `test --no-fail-fast`.
584
622
let failures = self . delayed_failures . borrow ( ) ;
585
623
if failures. len ( ) > 0 {
0 commit comments