@@ -53,7 +53,7 @@ use rustc_middle::ty::TyCtxt;
53
53
use rustc_parse:: { new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal} ;
54
54
use rustc_session:: config:: {
55
55
CG_OPTIONS , ErrorOutputType , Input , OptionDesc , OutFileName , OutputType , UnstableOptions ,
56
- Z_OPTIONS , nightly_options,
56
+ Z_OPTIONS , nightly_options, parse_target_triple ,
57
57
} ;
58
58
use rustc_session:: getopts:: { self , Matches } ;
59
59
use rustc_session:: lint:: { Lint , LintId } ;
@@ -1129,17 +1129,18 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) ->
1129
1129
/// Get the codegen backend based on the raw [`Matches`].
1130
1130
///
1131
1131
/// `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.
1134
1135
fn get_backend_from_raw_matches(
1135
1136
early_dcx: & EarlyDiagCtxt ,
1136
1137
matches: & Matches ,
1137
1138
) -> Box <dyn CodegenBackend > {
1138
1139
let debug_flags = matches. opt_strs( "Z" ) ;
1139
1140
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 ) ;
1141
1142
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) ;
1143
1144
1144
1145
get_codegen_backend( early_dcx, & sysroot, backend_name, & target)
1145
1146
}
0 commit comments