Skip to content

Commit c1b6637

Browse files
committed
Support --version and -Cpasses=list for other codegen backends
1 parent d96446c commit c1b6637

File tree

1 file changed

+16
-4
lines changed
  • compiler/rustc_driver/src

1 file changed

+16
-4
lines changed

compiler/rustc_driver/src/lib.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,16 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
765765
println!("commit-date: {}", unw(util::commit_date_str()));
766766
println!("host: {}", config::host_triple());
767767
println!("release: {}", unw(util::release_str()));
768-
get_codegen_backend(&None, None).print_version();
768+
769+
let debug_flags = matches.opt_strs("Z");
770+
let backend_name = debug_flags.iter().find_map(|x| {
771+
if x.starts_with("codegen-backend=") {
772+
Some(&x["codegen-backends=".len()..])
773+
} else {
774+
None
775+
}
776+
});
777+
get_codegen_backend(&None, backend_name).print_version();
769778
}
770779
}
771780

@@ -1037,8 +1046,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10371046
}
10381047

10391048
// Don't handle -W help here, because we might first load plugins.
1040-
let r = matches.opt_strs("Z");
1041-
if r.iter().any(|x| *x == "help") {
1049+
let debug_flags = matches.opt_strs("Z");
1050+
if debug_flags.iter().any(|x| *x == "help") {
10421051
describe_debug_flags();
10431052
return None;
10441053
}
@@ -1058,7 +1067,10 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10581067
}
10591068

10601069
if cg_flags.iter().any(|x| *x == "passes=list") {
1061-
get_codegen_backend(&None, None).print_passes();
1070+
let backend_name = debug_flags.iter().find_map(|x| {
1071+
if x.starts_with("codegen-backend=") { Some(&x["codegen-backends=".len()..]) } else { None }
1072+
});
1073+
get_codegen_backend(&None, backend_name).print_passes();
10621074
return None;
10631075
}
10641076

0 commit comments

Comments
 (0)