about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-20 15:47:26 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-20 15:47:26 +0000
commit056a9cebe97b52e5da1e35ba98d56050c5fc4a7a (patch)
tree0e1dd6aa74c406e0effa8a76f16d619fe44dfcb2 /compiler/rustc_driver_impl/src
parent3b6e3642cec8eebc7e9f88442a9d971287df3f6a (diff)
downloadrust-056a9cebe97b52e5da1e35ba98d56050c5fc4a7a.tar.gz
rust-056a9cebe97b52e5da1e35ba98d56050c5fc4a7a.zip
Respect --target in get_backend_from_raw_matches
Diffstat (limited to 'compiler/rustc_driver_impl/src')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 9e9394dec05..6543fe2b711 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -53,7 +53,7 @@ use rustc_middle::ty::TyCtxt;
 use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
 use rustc_session::config::{
     CG_OPTIONS, ErrorOutputType, Input, OptionDesc, OutFileName, OutputType, UnstableOptions,
-    Z_OPTIONS, nightly_options,
+    Z_OPTIONS, nightly_options, parse_target_triple,
 };
 use rustc_session::getopts::{self, Matches};
 use rustc_session::lint::{Lint, LintId};
@@ -1129,17 +1129,18 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) ->
 /// 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.
+/// arguments and created a [`Session`]. This function reads `-Zcodegen-backend`, `--target` 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 target = parse_target_triple(early_dcx, matches);
     let sysroot = filesearch::materialize_sysroot(matches.opt_str("sysroot").map(PathBuf::from));
-    let target = config::build_target_config(early_dcx, &opts, &sysroot);
+    let target = config::build_target_config(early_dcx, &target, &sysroot);
 
     get_codegen_backend(early_dcx, &sysroot, backend_name, &target)
 }