From eef524fadf1d7392d064267c84d6234e756e4780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Fri, 17 Jan 2025 14:02:32 +0100 Subject: [PATCH] Query runtime version of LLVM --- src/compiler/crystal/config.cr | 7 ++++++- src/llvm/lib_llvm/core.cr | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/compiler/crystal/config.cr b/src/compiler/crystal/config.cr index 2f71aa49815c..da85583de3aa 100644 --- a/src/compiler/crystal/config.cr +++ b/src/compiler/crystal/config.cr @@ -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 diff --git a/src/llvm/lib_llvm/core.cr b/src/llvm/lib_llvm/core.cr index 7137501fdb31..ef7b8f10b567 100644 --- a/src/llvm/lib_llvm/core.cr +++ b/src/llvm/lib_llvm/core.cr @@ -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)