@@ -30,6 +30,35 @@ if !isdir(libdir)
30
30
You might need a newer version of LLVM.jl for this version of Julia.""" )
31
31
end
32
32
33
+ # verify the LLVM library before importing LLVMExtra_jll (which may fail)
34
+ using Libdl
35
+ function loaded_llvm ()
36
+ # we only support working with the copy of LLVM that Julia uses, because we have
37
+ # additional library calls compiled in the Julia binary which cannot be used with
38
+ # another copy of LLVM. loading multiple copies of LLVM typically breaks anyhow.
39
+ if Base. libllvm_path () === nothing
40
+ error (""" Cannot find the LLVM library loaded by Julia.
41
+
42
+ Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
43
+ If you are, please file an issue and attach the output of `Libdl.dllist()`.""" )
44
+ end
45
+ path = Base. libllvm_path ()
46
+
47
+ # our JLL doesn't support LLVM with assertions yet, so loading LLVMExtra might fail.
48
+ # TODO : don't have LLVMExtra_jll eagerly dlopen so that we can verify this in __init__?
49
+ lib = Libdl. dlopen (path)
50
+ if Libdl. dlsym (lib, " _ZN4llvm23EnableABIBreakingChecksE" ; throw_error= false ) != = nothing
51
+ @warn """ You are using a version of Julia that links against a build of LLVM with assertions enabled.
52
+
53
+ This is not supported out-of-the-box, and you need a build of libLLVMExtra that supports this.
54
+ Use `deps/build_local.jl` for that, add the resulting LocalPreferences.toml to your project
55
+ and add a direct dependency on LLVMExtra_jll to pick up those preferences."""
56
+ end
57
+
58
+ return String (path)
59
+ end
60
+ loaded_llvm ()
61
+
33
62
import LLVMExtra_jll: libLLVMExtra
34
63
35
64
include (joinpath (libdir, llvm_version, " libLLVM_h.jl" ))
@@ -81,19 +110,7 @@ include("deprecated.jl")
81
110
82
111
function __init__ ()
83
112
# find the libLLVM loaded by Julia
84
- #
85
- # we only support working with the copy of LLVM that Julia uses, because we have
86
- # additional library calls compiled in the Julia binary which cannot be used with
87
- # another copy of LLVM. loading multiple copies of LLVM typically breaks anyhow.
88
- libllvm[] = let
89
- path = Base. libllvm_path ()
90
- if path === nothing
91
- error (""" Cannot find the LLVM library loaded by Julia.
92
- Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
93
- If you are, please file an issue and attach the output of `Libdl.dllist()`.""" )
94
- end
95
- String (path)
96
- end
113
+ libllvm[] = API. loaded_llvm ()
97
114
98
115
@debug " Using LLVM $(version ()) at $(Libdl. dlpath (libllvm[])) "
99
116
if version () != = runtime_version ()
0 commit comments