@@ -34,6 +34,7 @@ use std::ffi::OsString;
34
34
use std:: str:: FromStr ;
35
35
use std:: path:: PathBuf ;
36
36
use std:: process:: { Command , ExitStatus } ;
37
+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
37
38
38
39
fn main ( ) {
39
40
let mut args = env:: args_os ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
@@ -104,6 +105,7 @@ fn main() {
104
105
. env ( bootstrap:: util:: dylib_path_var ( ) ,
105
106
env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
106
107
108
+ let mut crate_name_opt = None ;
107
109
if let Some ( target) = target {
108
110
// The stage0 compiler has a special sysroot distinct from what we
109
111
// actually downloaded, so we just always pass the `--sysroot` option.
@@ -134,6 +136,7 @@ fn main() {
134
136
. find ( |a| & * a[ 0 ] == "--crate-name" )
135
137
. unwrap ( ) ;
136
138
let crate_name = & * crate_name[ 1 ] ;
139
+ crate_name_opt = crate_name. to_str ( ) ;
137
140
138
141
// If we're compiling specifically the `panic_abort` crate then we pass
139
142
// the `-C panic=abort` option. Note that we do not do this for any
@@ -282,9 +285,26 @@ fn main() {
282
285
eprintln ! ( "rustc command: {:?}" , cmd) ;
283
286
}
284
287
288
+ let do_timing = crate_name_opt. is_some ( ) &&
289
+ true ; // env::var("BOOTSTRAP_TIMING") == Ok("true".to_string());
290
+ if do_timing {
291
+ let dur = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) ;
292
+ eprintln ! ( "(BOOTSTRAP_TIMING start stage{} {} at {:?})" ,
293
+ stage, crate_name_opt. unwrap( ) , dur) ;
294
+ }
295
+ let after = || {
296
+ if do_timing {
297
+ let dur = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) ;
298
+ eprintln ! ( "(BOOTSTRAP_TIMING finish stage{} {} at {:?})" ,
299
+ stage, crate_name_opt. unwrap( ) , dur) ;
300
+ }
301
+ } ;
302
+
285
303
// Actually run the compiler!
286
304
std:: process:: exit ( if let Some ( ref mut on_fail) = on_fail {
287
- match cmd. status ( ) {
305
+ let st = cmd. status ( ) ;
306
+ after ( ) ;
307
+ match st {
288
308
Ok ( s) if s. success ( ) => 0 ,
289
309
_ => {
290
310
println ! ( "\n Did not run successfully:\n {:?}\n -------------" , cmd) ;
@@ -293,7 +313,15 @@ fn main() {
293
313
}
294
314
}
295
315
} else {
296
- std:: process:: exit ( match exec_cmd ( & mut cmd) {
316
+ let st =
317
+ if do_timing {
318
+ let st = cmd. status ( ) ;
319
+ after ( ) ;
320
+ st
321
+ } else {
322
+ exec_cmd ( & mut cmd)
323
+ } ;
324
+ std:: process:: exit ( match st {
297
325
Ok ( s) => s. code ( ) . unwrap_or ( 0xfe ) ,
298
326
Err ( e) => panic ! ( "\n \n failed to run {:?}: {}\n \n " , cmd, e) ,
299
327
} )
0 commit comments