Skip to content

Commit

Permalink
Fix compilation with LLVM 6.0
Browse files Browse the repository at this point in the history
This fixes symbol clashes with the LLVM C-API DebugInfo that was added
in LLVM 6.0.
  • Loading branch information
felixbuenemann committed Jul 13, 2018
1 parent 6a30458 commit 070c766
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/llvm/ext/llvm_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <llvm-c/DebugInfo.h>
#endif

#if LLVM_VERSION_GE(4, 0)
#include <llvm/Bitcode/BitcodeWriter.h>
#include <llvm/Analysis/ModuleSummaryAnalysis.h>
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/llvm/lib_llvm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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")}}
Expand Down
14 changes: 7 additions & 7 deletions src/llvm/lib_llvm_ext.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 070c766

Please sign in to comment.