Skip to content

Commit 5d30896

Browse files
committed
Override the target CPU if target_cpu is present
This is a fix for rust-lang#137739, and makes sure the "generic" CPU is never used when target_cpu is passed. This is particularly useful for architectures where knowing the exact CPU is a must, like AVR.
1 parent 8c39296 commit 5d30896

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ pub fn build_session(
978978
registry: rustc_errors::registry::Registry,
979979
fluent_resources: Vec<&'static str>,
980980
driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
981-
target: Target,
981+
mut target: Target,
982982
sysroot: PathBuf,
983983
cfg_version: &'static str,
984984
ice_file: Option<PathBuf>,
@@ -1067,6 +1067,9 @@ pub fn build_session(
10671067
let target_filesearch =
10681068
filesearch::FileSearch::new(&sopts.search_paths, &target_tlib_path, &target);
10691069
let host_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &host_tlib_path, &host);
1070+
if let Some(cpu) = &sopts.cg.target_cpu {
1071+
target.options.cpu = cpu.clone().into();
1072+
}
10701073
let sess = Session {
10711074
target,
10721075
host,

0 commit comments

Comments
 (0)