diff options
| author | bors <bors@rust-lang.org> | 2018-08-29 02:08:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-08-29 02:08:02 +0000 |
| commit | 9d69e81e9b400805b0453b9262958c8e28faa8a0 (patch) | |
| tree | a2683e57d8b6c9eaf1044fe7b6d6b8389c7ff532 /src/rustllvm/PassWrapper.cpp | |
| parent | f1d02c307348057fd0554ad934006b186f8b6826 (diff) | |
| parent | 1fd45a13dee17701fc0aeaa847c1919d485d09fd (diff) | |
| download | rust-9d69e81e9b400805b0453b9262958c8e28faa8a0.tar.gz rust-9d69e81e9b400805b0453b9262958c8e28faa8a0.zip | |
Auto merge of #53642 - alexcrichton:fix-target-cpu-native, r=arielb1
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/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 46825efeee2..09befdaae37 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -359,6 +359,12 @@ extern "C" void LLVMRustPrintTargetFeatures(LLVMTargetMachineRef) { } #endif +extern "C" const char* LLVMRustGetHostCPUName(size_t *len) { + StringRef Name = sys::getHostCPUName(); + *len = Name.size(); + return Name.data(); +} + extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( const char *TripleStr, const char *CPU, const char *Feature, LLVMRustCodeModel RustCM, LLVMRustRelocMode RustReloc, @@ -381,11 +387,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( return nullptr; } - StringRef RealCPU = CPU; - if (RealCPU == "native") { - RealCPU = sys::getHostCPUName(); - } - TargetOptions Options; Options.FloatABIType = FloatABI::Default; @@ -417,7 +418,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( if (RustCM != LLVMRustCodeModel::None) CM = fromRust(RustCM); TargetMachine *TM = TheTarget->createTargetMachine( - Trip.getTriple(), RealCPU, Feature, Options, RM, CM, OptLevel); + Trip.getTriple(), CPU, Feature, Options, RM, CM, OptLevel); return wrap(TM); } |
