about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
diff options
context:
space:
mode:
authorJulian Orth <ju.orth@gmail.com>2015-03-10 01:46:45 +0100
committerJulian Orth <ju.orth@gmail.com>2015-03-10 01:56:51 +0100
commit660b48fae5f54c4a4994b8c23550f580927775ab (patch)
tree3d9a14ec3ef46f5ff3833cb58e2d12176e736f68 /src/rustllvm/PassWrapper.cpp
parent638832e64cc62ec46721161ca19731ba00d4da58 (diff)
downloadrust-660b48fae5f54c4a4994b8c23550f580927775ab.tar.gz
rust-660b48fae5f54c4a4994b8c23550f580927775ab.zip
Add support for target-cpu=native
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
-rw-r--r--src/rustllvm/PassWrapper.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index ce3090390db..b205d87598c 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -14,6 +14,7 @@
 
 #include "llvm/Support/CBindingWrapping.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 
@@ -83,6 +84,11 @@ LLVMRustCreateTargetMachine(const char *triple,
         return NULL;
     }
 
+    StringRef real_cpu = cpu;
+    if (real_cpu == "native") {
+        real_cpu = sys::getHostCPUName();
+    }
+
     TargetOptions Options;
     Options.PositionIndependentExecutable = PositionIndependentExecutable;
     Options.NoFramePointerElim = NoFramePointerElim;
@@ -96,7 +102,7 @@ LLVMRustCreateTargetMachine(const char *triple,
     }
 
     TargetMachine *TM = TheTarget->createTargetMachine(Trip.getTriple(),
-                                                       cpu,
+                                                       real_cpu,
                                                        feature,
                                                        Options,
                                                        RM,