From 2838e1b5de8f96604e36c0e3d6c87afb63f4124a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 26 Oct 2016 07:21:19 +0200 Subject: [PATCH] Compile fix for macOS --- src/r_compiler/llvm_include.h | 4 ++++ src/r_compiler/llvmdrawers.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index c51143c58..75952d1f9 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -55,6 +55,10 @@ #include #include +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) +#include +#endif + #ifdef __APPLE__ #pragma clang diagnostic pop #endif diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index ba1fb4efc..2f8609f68 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -474,7 +474,11 @@ void LLVMProgram::CreateEE() if (!machine) I_FatalError("Could not create LLVM target machine"); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif std::string cpuName = machine->getTargetCPU(); Printf("LLVM target triple: %s\n", targetTriple.c_str()); Printf("LLVM target CPU: %s\n", cpuName.c_str()); @@ -540,7 +544,11 @@ std::string LLVMProgram::GenerateAssembly(std::string cpuName) if (!machine) I_FatalError("Could not create LLVM target machine"); +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + std::string targetTriple = machine->getTargetTriple(); +#else std::string targetTriple = machine->getTargetTriple().getTriple(); +#endif module->setTargetTriple(targetTriple); #if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) @@ -558,9 +566,13 @@ std::string LLVMProgram::GenerateAssembly(std::string cpuName) #endif SmallString<16*1024> str; +#if LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 8) + raw_svector_ostream vecstream(str); + formatted_raw_ostream stream(vecstream); +#else raw_svector_ostream stream(str); +#endif machine->addPassesToEmitFile(PerModulePasses, stream, TargetMachine::CGFT_AssemblyFile); - PerModulePasses.add(createPrintMIRPass(stream)); PassManagerBuilder passManagerBuilder; passManagerBuilder.OptLevel = 3;