diff --git a/src/llvm/ext/llvm_ext.cc b/src/llvm/ext/llvm_ext.cc index 67a1adcd074a..f675bacdf979 100644 --- a/src/llvm/ext/llvm_ext.cc +++ b/src/llvm/ext/llvm_ext.cc @@ -20,6 +20,10 @@ using namespace llvm; #define LLVM_VERSION_LE(major, minor) \ (LLVM_VERSION_MAJOR < (major) || LLVM_VERSION_MAJOR == (major) && LLVM_VERSION_MINOR <= (minor)) +#if LLVM_VERSION_GE(6, 0) +#include +#endif + #if LLVM_VERSION_GE(4, 0) #include #include @@ -56,14 +60,16 @@ LLVMDIBuilderRef LLVMNewDIBuilder(LLVMModuleRef mref) { return wrap(new DIBuilder(*m)); } +#if LLVM_VERSION_LE(5, 9) void LLVMDIBuilderFinalize(LLVMDIBuilderRef dref) { unwrap(dref)->finalize(); } +#endif -LLVMMetadataRef LLVMDIBuilderCreateFile(DIBuilderRef Dref, const char *File, +LLVMMetadataRef LLVMDIBuilderCreateFile2(DIBuilderRef Dref, const char *File, const char *Dir) { return wrap(Dref->createFile(File, Dir)); } -LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(DIBuilderRef Dref, unsigned Lang, +LLVMMetadataRef LLVMDIBuilderCreateCompileUnit2(DIBuilderRef Dref, unsigned Lang, const char *File, const char *Dir, const char *Producer, diff --git a/src/llvm/lib_llvm.cr b/src/llvm/lib_llvm.cr index 02b1d8f22a57..7ccb7c76f102 100644 --- a/src/llvm/lib_llvm.cr +++ b/src/llvm/lib_llvm.cr @@ -31,6 +31,7 @@ end {% begin %} lib LibLLVM + IS_60 = {{LibLLVM::VERSION.starts_with?("6.0")}} IS_50 = {{LibLLVM::VERSION.starts_with?("5.0")}} IS_40 = {{LibLLVM::VERSION.starts_with?("4.0")}} IS_39 = {{LibLLVM::VERSION.starts_with?("3.9")}} diff --git a/src/llvm/lib_llvm_ext.cr b/src/llvm/lib_llvm_ext.cr index b5e9bc418314..31e8ede1dea9 100644 --- a/src/llvm/lib_llvm_ext.cr +++ b/src/llvm/lib_llvm_ext.cr @@ -20,13 +20,13 @@ lib LibLLVMExt scope_line : UInt, flags : LLVM::DIFlags, is_optimized : Bool, func : LibLLVM::ValueRef ) : Metadata - fun di_builder_create_file = LLVMDIBuilderCreateFile(builder : DIBuilder, file : Char*, dir : Char*) : Metadata - fun di_builder_create_compile_unit = LLVMDIBuilderCreateCompileUnit(builder : DIBuilder, - lang : UInt, file : Char*, - dir : Char*, - producer : Char*, - optimized : Int, flags : Char*, - runtime_version : UInt) : Metadata + fun di_builder_create_file = LLVMDIBuilderCreateFile2(builder : DIBuilder, file : Char*, dir : Char*) : Metadata + fun di_builder_create_compile_unit = LLVMDIBuilderCreateCompileUnit2(builder : DIBuilder, + lang : UInt, file : Char*, + dir : Char*, + producer : Char*, + optimized : Int, flags : Char*, + runtime_version : UInt) : Metadata fun di_builder_create_lexical_block = LLVMDIBuilderCreateLexicalBlock(builder : DIBuilder, scope : Metadata, file : Metadata,