diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-08-23 11:03:22 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-08-28 13:32:11 -0700 |
| commit | 1fd45a13dee17701fc0aeaa847c1919d485d09fd (patch) | |
| tree | 8ca2cb2677b213994b44f037798db56d0c867d15 /src/librustc_codegen_llvm/back | |
| parent | 7061b2775782bb48c0a70d3c79ec711134396687 (diff) | |
| download | rust-1fd45a13dee17701fc0aeaa847c1919d485d09fd.tar.gz rust-1fd45a13dee17701fc0aeaa847c1919d485d09fd.zip | |
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
Diffstat (limited to 'src/librustc_codegen_llvm/back')
| -rw-r--r-- | src/librustc_codegen_llvm/back/linker.rs | 3 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/back/write.rs | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs index a429e8f2d81..eee60b262a1 100644 --- a/src/librustc_codegen_llvm/back/linker.rs +++ b/src/librustc_codegen_llvm/back/linker.rs @@ -26,6 +26,7 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo, use rustc::ty::TyCtxt; use rustc_target::spec::{LinkerFlavor, LldFlavor}; use serialize::{json, Encoder}; +use llvm_util; /// For all the linkers we support, and information they might /// need out of the shared crate context before we get rid of it. @@ -202,7 +203,7 @@ impl<'a> GccLinker<'a> { }; self.linker_arg(&format!("-plugin-opt={}", opt_level)); - self.linker_arg(&format!("-plugin-opt=mcpu={}", self.sess.target_cpu())); + self.linker_arg(&format!("-plugin-opt=mcpu={}", llvm_util::target_cpu(self.sess))); match self.sess.opts.cg.lto { config::Lto::Thin | 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::<Vec<_>>() .join(","); |
