clang-interpreter: interpret instead of JITing
Fixes the build when no targets are selected, or no native target is built.
This also better matches up with the description/title of the example and
demonstrates how clang can be used to run C++ on constrained environments
without file IO or executable memory permissions (e.g. iOS apps).
A comment is added explaining how to extend the demo with JIT support as
needed.
llvm-svn: 212083
diff --git a/clang/examples/clang-interpreter/main.cpp b/clang/examples/clang-interpreter/main.cpp
index 0f083c1..c255f51 100644
--- a/clang/examples/clang-interpreter/main.cpp
+++ b/clang/examples/clang-interpreter/main.cpp
@@ -18,7 +18,6 @@
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
@@ -43,11 +42,12 @@
}
static int Execute(llvm::Module *Mod, char * const *envp) {
- llvm::InitializeNativeTarget();
+ // To JIT instead of interpreting, call llvm::InitializeNativeTarget() here
+ // and pass ForceInterpreter=false to ExecutionEngine::create().
std::string Error;
std::unique_ptr<llvm::ExecutionEngine> EE(
- llvm::ExecutionEngine::createJIT(Mod, &Error));
+ llvm::ExecutionEngine::create(Mod, /*ForceInterpreter*/ true, &Error));
if (!EE) {
llvm::errs() << "unable to make execution engine: " << Error << "\n";
return 255;