Skip to content

Commit

Permalink
Query runtime version of LLVM
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Jan 18, 2025
1 parent 2b544f1 commit eef524f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/compiler/crystal/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ module Crystal
end

def self.llvm_version
LibLLVM::VERSION
{% if LibLLVM.has_method?(:get_version) %}
LibLLVM.get_version(out major, out minor, out patch)
"#{major}.#{minor}.#{patch}"
{% else %}
LibLLVM::VERSION
{% end %}
end

def self.description
Expand Down
4 changes: 4 additions & 0 deletions src/llvm/lib_llvm/core.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ lib LibLLVM

fun dispose_message = LLVMDisposeMessage(message : Char*)

{% unless LibLLVM::IS_LT_160 %}
fun get_version = LLVMGetVersion(major : UInt*, minor : UInt*, patch : UInt*) : Void
{% end %}

fun create_context = LLVMContextCreate : ContextRef
fun dispose_context = LLVMContextDispose(c : ContextRef)

Expand Down

0 comments on commit eef524f

Please sign in to comment.