Skip to content

Commit 2634f52

Browse files
authored
Merge pull request #300 from maleadt/tb/path
Don't hard-code path to libLLVM.
2 parents 200404e + 926e5b3 commit 2634f52

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/LLVM.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@ using Libdl
1010
include("base.jl")
1111
include("version.jl")
1212

13-
const libllvm = Base.libllvm_path()
14-
if libllvm === nothing
15-
error("""Cannot find the LLVM library loaded by Julia.
16-
17-
Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
18-
If you are, please file an issue and attach the output of `Libdl.dllist()`.""")
19-
end
13+
# we don't embed the full path to LLVM, because the location might be different at run time.
14+
const libllvm = basename(String(Base.libllvm_path()))
15+
const libllvm_version = Base.libllvm_version
2016

2117
module API
2218
using CEnum
2319
using ..LLVM
2420
using ..LLVM: libllvm
2521

26-
llvm_version = if version() < v"12"
22+
const llvm_version = if version() < v"12"
2723
"11"
2824
elseif version().major == 12
2925
"12"
3026
else
3127
"13"
3228
end
33-
libdir = joinpath(@__DIR__, "..", "lib")
29+
const libdir = joinpath(@__DIR__, "..", "lib")
3430

3531
if !isdir(libdir)
3632
error("""
@@ -87,13 +83,20 @@ include("deprecated.jl")
8783
## initialization
8884

8985
function __init__()
86+
@debug "Using LLVM $libllvm_version at $(Base.libllvm_path())"
87+
9088
# sanity checks
91-
@debug "Using LLVM $(version()) at $libllvm"
92-
if libllvm != Base.libllvm_path()
93-
@error "Mismatch between LLVM library used during precompilation ($libllvm) and the current run-time situation ($(Base.libllvm_path())). Please recompile the package."
89+
if libllvm_version != Base.libllvm_version
90+
# this checks that the precompilation image isn't being used
91+
# after having upgraded Julia and the contained LLVM library.
92+
@error """LLVM.jl was precompiled for LLVM $libllvm_version, whereas you are now using LLVM $(Base.libllvm_version).
93+
Please re-compile LLVM.jl."""
9494
end
9595
if version() !== runtime_version()
96-
@error "Using a different version of LLVM ($(runtime_version())) than the one shipped with Julia ($(version())); this is unsupported"
96+
# this is probably caused by a combination of USE_SYSTEM_LLVM
97+
# and an LLVM upgrade without recompiling Julia.
98+
@error """Julia was compiled for LLVM $(version()), whereas you are now using LLVM $(runtime_version()).
99+
Please re-compile Julia and LLVM.jl (but note that USE_SYSTEM_LLVM is not a supported configuration)."""
97100
end
98101

99102
_install_handlers()

src/version.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export version
44

5-
version() = Base.libllvm_version
5+
version() = libllvm_version
66

77
function runtime_version()
88
# FIXME: add a proper C API to LLVM

0 commit comments

Comments
 (0)