@@ -53,7 +53,7 @@ use rustc_middle::ty::TyCtxt;
5353use rustc_parse:: { new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal} ;
5454use rustc_session:: config:: {
5555 CG_OPTIONS , ErrorOutputType , Input , OptionDesc , OutFileName , OutputType , UnstableOptions ,
56- Z_OPTIONS , nightly_options,
56+ Z_OPTIONS , nightly_options, parse_target_triple ,
5757} ;
5858use rustc_session:: getopts:: { self , Matches } ;
5959use rustc_session:: lint:: { Lint , LintId } ;
@@ -1129,17 +1129,18 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) ->
11291129/// Get the codegen backend based on the raw [`Matches`].
11301130///
11311131/// `rustc -vV` and `rustc -Cpasses=list` need to get the codegen backend before we have parsed all
1132- /// arguments and created a [`Session`]. This function reads `-Zcodegen-backend` and `--sysroot`
1133- /// without validating any other arguments and loads the codegen backend based on these arguments.
1132+ /// arguments and created a [`Session`]. This function reads `-Zcodegen-backend`, `--target` and
1133+ /// `--sysroot` without validating any other arguments and loads the codegen backend based on these
1134+ /// arguments.
11341135fn get_backend_from_raw_matches(
11351136 early_dcx: & EarlyDiagCtxt ,
11361137 matches: & Matches ,
11371138) -> Box <dyn CodegenBackend > {
11381139 let debug_flags = matches. opt_strs( "Z" ) ;
11391140 let backend_name = debug_flags. iter( ) . find_map( |x| x. strip_prefix( "codegen-backend=" ) ) ;
1140- let opts = config :: Options :: default ( ) ;
1141+ let target = parse_target_triple ( early_dcx , matches ) ;
11411142 let sysroot = filesearch:: materialize_sysroot( matches. opt_str( "sysroot" ) . map( PathBuf :: from) ) ;
1142- let target = config:: build_target_config( early_dcx, & opts , & sysroot) ;
1143+ let target = config:: build_target_config( early_dcx, & target , & sysroot) ;
11431144
11441145 get_codegen_backend( early_dcx, & sysroot, backend_name, & target)
11451146}
0 commit comments