From 1fd45a13dee17701fc0aeaa847c1919d485d09fd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 23 Aug 2018 11:03:22 -0700 Subject: Fix warnings about the `native` target-cpu This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322 --- src/librustc_codegen_llvm/back/write.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/librustc_codegen_llvm/back/write.rs') diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 80e9965e39c..2373428d68c 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -25,6 +25,7 @@ use rustc::session::Session; use rustc::util::nodemap::FxHashMap; use time_graph::{self, TimeGraph, Timeline}; use llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic}; +use llvm_util; use {CodegenResults, ModuleSource, ModuleCodegen, CompiledModule, ModuleKind}; use CrateInfo; use rustc::hir::def_id::{CrateNum, LOCAL_CRATE}; @@ -173,7 +174,7 @@ pub fn target_machine_factory(sess: &Session, find_features: bool) let singlethread = sess.target.target.options.singlethread; let triple = SmallCStr::new(&sess.target.target.llvm_target); - let cpu = SmallCStr::new(sess.target_cpu()); + let cpu = SmallCStr::new(llvm_util::target_cpu(sess)); let features = attributes::llvm_target_features(sess) .collect::>() .join(","); -- cgit 1.4.1-3-g733a5