Skip to content

Commit 6d71ce5

Browse files
committed
Auto merge of #26599 - richo:richo-stage-info, r=brson
This will add information about the stage that a rustc was built with to the verbose version info I have symlinks into $(HOST)/stage{0,1,2} into the rust version switcher thing I use, and occasionally need to know which stage a given rustc is.
2 parents 9d9e267 + e66ac43 commit 6d71ce5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustc_driver/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,17 @@ pub fn commit_date_str() -> Option<&'static str> {
481481
option_env!("CFG_VER_DATE")
482482
}
483483

484+
/// Returns a stage string, such as "stage0".
485+
pub fn stage_str() -> Option<&'static str> {
486+
if cfg!(stage0) {
487+
Some("stage0")
488+
} else if cfg!(stage1) {
489+
Some("stage1")
490+
} else {
491+
None
492+
}
493+
}
494+
484495
/// Prints version information
485496
pub fn version(binary: &str, matches: &getopts::Matches) {
486497
let verbose = matches.opt_present("verbose");
@@ -493,6 +504,9 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
493504
println!("commit-date: {}", unw(commit_date_str()));
494505
println!("host: {}", config::host_triple());
495506
println!("release: {}", unw(release_str()));
507+
if let Some(stage) = stage_str() {
508+
println!("stage: {}", stage);
509+
}
496510
}
497511
}
498512

0 commit comments

Comments
 (0)