Skip to content

Commit 7000c93

Browse files
committed
Write start and finish times from bootstrap rustc
DO NOT MERGE
1 parent 604d4ce commit 7000c93

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ matrix:
1212
fast_finish: true
1313
include:
1414
# Images used in testing PR and try-build should be run first.
15-
- env: IMAGE=x86_64-gnu-llvm-3.9 RUST_BACKTRACE=1
15+
- env: IMAGE=x86_64-gnu-llvm-3.9 RUST_BACKTRACE=1 BOOTSTRAP_TIMING=true
1616
if: type = pull_request OR branch = auto
1717

1818
- env: IMAGE=dist-x86_64-linux DEPLOY=1

src/bootstrap/bin/rustc.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::ffi::OsString;
3434
use std::str::FromStr;
3535
use std::path::PathBuf;
3636
use std::process::{Command, ExitStatus};
37+
use std::time::{SystemTime, UNIX_EPOCH};
3738

3839
fn main() {
3940
let mut args = env::args_os().skip(1).collect::<Vec<_>>();
@@ -104,6 +105,7 @@ fn main() {
104105
.env(bootstrap::util::dylib_path_var(),
105106
env::join_paths(&dylib_path).unwrap());
106107

108+
let mut crate_name_opt = None;
107109
if let Some(target) = target {
108110
// The stage0 compiler has a special sysroot distinct from what we
109111
// actually downloaded, so we just always pass the `--sysroot` option.
@@ -134,6 +136,7 @@ fn main() {
134136
.find(|a| &*a[0] == "--crate-name")
135137
.unwrap();
136138
let crate_name = &*crate_name[1];
139+
crate_name_opt = crate_name.to_str();
137140

138141
// If we're compiling specifically the `panic_abort` crate then we pass
139142
// the `-C panic=abort` option. Note that we do not do this for any
@@ -282,9 +285,26 @@ fn main() {
282285
eprintln!("rustc command: {:?}", cmd);
283286
}
284287

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+
285303
// Actually run the compiler!
286304
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 {
288308
Ok(s) if s.success() => 0,
289309
_ => {
290310
println!("\nDid not run successfully:\n{:?}\n-------------", cmd);
@@ -293,7 +313,15 @@ fn main() {
293313
}
294314
}
295315
} 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 {
297325
Ok(s) => s.code().unwrap_or(0xfe),
298326
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
299327
})

0 commit comments

Comments
 (0)