Index: ../llvm-trunk/examples/BrainF/BrainFDriver.cpp =================================================================== --- ../llvm-trunk/examples/BrainF/BrainFDriver.cpp +++ ../llvm-trunk/examples/BrainF/BrainFDriver.cpp @@ -29,6 +29,7 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/ExecutionEngine/MCJIT.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -153,13 +154,20 @@ //Write it out if (JIT) { InitializeNativeTarget(); + InitializeNativeTargetAsmPrinter(); outs() << "------- Running JIT -------\n"; Module &M = *Mod; ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create(); + if (ee == NULL) { + errs() << "Error: execution engine creation failed.\n"; + abort(); + } std::vector args; Function *brainf_func = M.getFunction("brainf"); GenericValue gv = ee->runFunction(brainf_func, args); + //flush putchar output buffer + fflush(stdout); } else { WriteBitcodeToFile(Mod.get(), *out); } Index: ../llvm-trunk/examples/BrainF/CMakeLists.txt =================================================================== --- ../llvm-trunk/examples/BrainF/CMakeLists.txt +++ ../llvm-trunk/examples/BrainF/CMakeLists.txt @@ -3,6 +3,7 @@ Core ExecutionEngine MC + MCJIT Support nativecodegen )