Skip to content

Commit ae81a72

Browse files
committed
Use jl_get_libllvm to locate libLLVM.
1 parent b6eafc9 commit ae81a72

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/LLVM.jl

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,29 @@ function __init__()
6060
# we only support working with the copy of LLVM that Julia uses, because we have
6161
# additional library calls compiled in the Julia binary which cannot be used with
6262
# another copy of LLVM. loading multiple copies of LLVM typically breaks anyhow.
63-
libllvm_paths = filter(Libdl.dllist()) do lib
64-
occursin(r"LLVM\b", basename(lib))
63+
libllvm[] = if VERSION >= v"1.6.0-DEV.1356"
64+
path = Base.libllvm()
65+
if path === nothing
66+
error("""Cannot find the LLVM library loaded by Julia.
67+
Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
68+
If you are, please file an issue and attach the output of `Libdl.dllist()`.""")
69+
end
70+
String(path)
71+
else
72+
libllvm_paths = filter(Libdl.dllist()) do lib
73+
occursin(r"LLVM\b", basename(lib))
74+
end
75+
if isempty(libllvm_paths)
76+
error("""Cannot find the LLVM library loaded by Julia.
77+
Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
78+
If you are, please file an issue and attach the output of `Libdl.dllist()`.""")
79+
end
80+
if length(libllvm_paths) > 1
81+
error("""Multiple LLVM libraries loaded by Julia.
82+
Please file an issue and attach the output of `Libdl.dllist()`.""")
83+
end
84+
first(libllvm_paths)
6585
end
66-
if isempty(libllvm_paths)
67-
error("""
68-
Cannot find the LLVM library loaded by Julia.
69-
Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
70-
If you are, please file an issue and attach the output of `Libdl.dllist()`.""")
71-
end
72-
if length(libllvm_paths) > 1
73-
error("""
74-
Multiple LLVM libraries loaded by Julia.
75-
Please file an issue and attach the output of `Libdl.dllist()`.""")
76-
end
77-
libllvm[] = first(libllvm_paths)
7886

7987
@debug "Using LLVM $(version()) at $(Libdl.dlpath(libllvm[]))"
8088
if version() !== runtime_version()

0 commit comments

Comments
 (0)