Respect --sysroot for rustc -vV and -Cpasses=list
This is necessary when the specified codegen backend is in a custom sysroot.
This commit is contained in:
parent
67951d946a
commit
3b6e3642ce
1 changed files with 20 additions and 14 deletions
|
@ -916,13 +916,7 @@ pub fn version_at_macro_invocation(
|
||||||
safe_println!("host: {}", config::host_tuple());
|
safe_println!("host: {}", config::host_tuple());
|
||||||
safe_println!("release: {release}");
|
safe_println!("release: {release}");
|
||||||
|
|
||||||
let debug_flags = matches.opt_strs("Z");
|
get_backend_from_raw_matches(early_dcx, matches).print_version();
|
||||||
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
|
|
||||||
let opts = config::Options::default();
|
|
||||||
let sysroot = filesearch::materialize_sysroot(opts.maybe_sysroot.clone());
|
|
||||||
let target = config::build_target_config(early_dcx, &opts, &sysroot);
|
|
||||||
|
|
||||||
get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_version();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,19 +1119,31 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
if cg_flags.iter().any(|x| *x == "passes=list") {
|
if cg_flags.iter().any(|x| *x == "passes=list") {
|
||||||
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
|
get_backend_from_raw_matches(early_dcx, matches).print_passes();
|
||||||
|
|
||||||
let opts = config::Options::default();
|
|
||||||
let sysroot = filesearch::materialize_sysroot(opts.maybe_sysroot.clone());
|
|
||||||
let target = config::build_target_config(early_dcx, &opts, &sysroot);
|
|
||||||
|
|
||||||
get_codegen_backend(early_dcx, &sysroot, backend_name, &target).print_passes();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the codegen backend based on the raw [`Matches`].
|
||||||
|
///
|
||||||
|
/// `rustc -vV` and `rustc -Cpasses=list` need to get the codegen backend before we have parsed all
|
||||||
|
/// arguments and created a [`Session`]. This function reads `-Zcodegen-backend` and `--sysroot`
|
||||||
|
/// without validating any other arguments and loads the codegen backend based on these arguments.
|
||||||
|
fn get_backend_from_raw_matches(
|
||||||
|
early_dcx: &EarlyDiagCtxt,
|
||||||
|
matches: &Matches,
|
||||||
|
) -> Box<dyn CodegenBackend> {
|
||||||
|
let debug_flags = matches.opt_strs("Z");
|
||||||
|
let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend="));
|
||||||
|
let opts = config::Options::default();
|
||||||
|
let sysroot = filesearch::materialize_sysroot(matches.opt_str("sysroot").map(PathBuf::from));
|
||||||
|
let target = config::build_target_config(early_dcx, &opts, &sysroot);
|
||||||
|
|
||||||
|
get_codegen_backend(early_dcx, &sysroot, backend_name, &target)
|
||||||
|
}
|
||||||
|
|
||||||
fn describe_debug_flags() {
|
fn describe_debug_flags() {
|
||||||
safe_println!("\nAvailable options:\n");
|
safe_println!("\nAvailable options:\n");
|
||||||
print_flag_list("-Z", config::Z_OPTIONS);
|
print_flag_list("-Z", config::Z_OPTIONS);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue