@@ -11,58 +11,62 @@ using Libdl
11
11
12
12
VERSION >= v " 0.7.0-DEV.2576" || error (" This version of LLVM.jl requires Julia 0.7" )
13
13
14
- # figure out the path to libLLVM by looking at the libraries loaded by Julia
15
- const libllvm_paths = filter (Libdl. dllist ()) do lib
16
- occursin (" LLVM" , basename (lib))
17
- end
18
- if isempty (libllvm_paths)
19
- error ("""
20
- Cannot find the LLVM library loaded by Julia.
21
- Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
22
- If you are, please file an issue and attach the output of `Libdl.dllist()`.""" )
23
- end
24
- if length (libllvm_paths) > 1
25
- error ("""
26
- Multiple LLVM libraries loaded by Julia.
27
- Please file an issue and attach the output of `Libdl.dllist()`.""" )
28
- end
29
- const libllvm = first (libllvm_paths)
30
- const libllvm_version = Base. libllvm_version:: VersionNumber
31
- @debug " Discovered LLVM v$libllvm_version at $libllvm "
32
- Base. include_dependency (libllvm)
33
-
34
- vercmp_match (a,b) = a. major== b. major && a. minor== b. minor
35
- vercmp_compat (a,b) = a. major> b. major || (a. major== b. major && a. minor>= b. minor)
36
-
37
- const llvmjl_wrappers_path = joinpath (@__DIR__ , " .." , " lib" )
38
- Base. include_dependency (llvmjl_wrappers_path)
39
-
40
- const llvmjl_wrappers = filter (path-> isdir (joinpath (llvmjl_wrappers_path, path)),
41
- readdir (llvmjl_wrappers_path))
42
- @assert ! isempty (llvmjl_wrappers)
43
-
44
- # figure out which wrapper to use
45
- const matching_wrappers = filter (wrapper-> vercmp_match (libllvm_version,
46
- VersionNumber (wrapper)),
47
- llvmjl_wrappers)
48
- const llvmjl_wrapper = if ! isempty (matching_wrappers)
49
- @assert length (matching_wrappers) == 1
50
- matching_wrappers[1 ]
51
- else
52
- compatible_wrappers = filter (wrapper-> vercmp_compat (libllvm_version,
53
- VersionNumber (wrapper)),
54
- llvmjl_wrappers)
55
- isempty (compatible_wrappers) && error (" Could not find any compatible wrapper for LLVM $(libllvm_version) " )
56
- last (compatible_wrappers)
57
- end
58
- @debug " Using LLVM.jl wrapper for v$llvmjl_wrapper "
14
+ let
15
+ # find LLVM library
16
+
17
+ libllvm_paths = filter (Libdl. dllist ()) do lib
18
+ occursin (" LLVM" , basename (lib))
19
+ end
20
+ if isempty (libllvm_paths)
21
+ error ("""
22
+ Cannot find the LLVM library loaded by Julia.
23
+ Please use a version of Julia that has been built with USE_LLVM_SHLIB=1 (like the official binaries).
24
+ If you are, please file an issue and attach the output of `Libdl.dllist()`.""" )
25
+ end
26
+ if length (libllvm_paths) > 1
27
+ error ("""
28
+ Multiple LLVM libraries loaded by Julia.
29
+ Please file an issue and attach the output of `Libdl.dllist()`.""" )
30
+ end
31
+ global const libllvm = first (libllvm_paths)
32
+ Base. include_dependency (libllvm)
59
33
60
- # TODO : figure out the name of the native target
61
- const libllvm_targets = [:NVPTX , :AMDGPU ]
34
+ global const libllvm_version = Base. libllvm_version:: VersionNumber
62
35
63
- # backwards-compatible flags
64
- const libllvm_system = false
65
- const configured = true
36
+ # TODO : figure out the name of the native target
37
+ global const libllvm_targets = [:NVPTX , :AMDGPU ]
38
+
39
+ @debug " Found LLVM v$libllvm_version at $libllvm with support for $(join (libllvm_targets, " , " )) "
40
+
41
+
42
+ # find appropriate LLVM.jl wrapper
43
+
44
+ vercmp_match (a,b) = a. major== b. major && a. minor== b. minor
45
+ vercmp_compat (a,b) = a. major> b. major || (a. major== b. major && a. minor>= b. minor)
46
+
47
+ llvmjl_wrappers_path = joinpath (@__DIR__ , " .." , " lib" )
48
+ Base. include_dependency (llvmjl_wrappers_path)
49
+
50
+ llvmjl_wrappers = filter (path-> isdir (joinpath (llvmjl_wrappers_path, path)),
51
+ readdir (llvmjl_wrappers_path))
52
+ @assert ! isempty (llvmjl_wrappers)
53
+
54
+ matching_wrappers = filter (wrapper-> vercmp_match (libllvm_version,
55
+ VersionNumber (wrapper)),
56
+ llvmjl_wrappers)
57
+ global const llvmjl_wrapper = if ! isempty (matching_wrappers)
58
+ @assert length (matching_wrappers) == 1
59
+ matching_wrappers[1 ]
60
+ else
61
+ compatible_wrappers = filter (wrapper-> vercmp_compat (libllvm_version,
62
+ VersionNumber (wrapper)),
63
+ llvmjl_wrappers)
64
+ isempty (compatible_wrappers) && error (" Could not find any compatible wrapper for LLVM $(libllvm_version) " )
65
+ last (compatible_wrappers)
66
+ end
67
+
68
+ @debug " Using LLVM.jl wrapper for LLVM v$llvmjl_wrapper "
69
+ end
66
70
67
71
68
72
# # source code includes
0 commit comments