Skip to content

Commit 6bb0540

Browse files
lazify SuiteSparse_jll
1 parent 089ecb7 commit 6bb0540

File tree

1 file changed

+93
-95
lines changed

1 file changed

+93
-95
lines changed

stdlib/SuiteSparse_jll/src/SuiteSparse_jll.jl

Lines changed: 93 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -4,137 +4,135 @@
44
baremodule SuiteSparse_jll
55
using Base, Libdl, libblastrampoline_jll
66

7-
const PATH_list = String[]
8-
const LIBPATH_list = String[]
9-
107
export libamd, libbtf, libcamd, libccolamd, libcholmod, libcolamd, libklu, libldl, librbio, libspqr, libsuitesparseconfig, libumfpack
118

129
# These get calculated in __init__()
1310
# Man I can't wait until these are automatically handled by an in-Base JLLWrappers clone.
1411
const PATH = Ref("")
12+
const PATH_list = String[]
1513
const LIBPATH = Ref("")
14+
const LIBPATH_list = String[]
1615
artifact_dir::String = ""
17-
libamd_handle::Ptr{Cvoid} = C_NULL
1816
libamd_path::String = ""
19-
libbtf_handle::Ptr{Cvoid} = C_NULL
2017
libbtf_path::String = ""
21-
libcamd_handle::Ptr{Cvoid} = C_NULL
2218
libcamd_path::String = ""
23-
libccolamd_handle::Ptr{Cvoid} = C_NULL
2419
libccolamd_path::String = ""
25-
libcholmod_handle::Ptr{Cvoid} = C_NULL
2620
libcholmod_path::String = ""
27-
libcolamd_handle::Ptr{Cvoid} = C_NULL
2821
libcolamd_path::String = ""
29-
libklu_handle::Ptr{Cvoid} = C_NULL
3022
libklu_path::String = ""
31-
libldl_handle::Ptr{Cvoid} = C_NULL
3223
libldl_path::String = ""
33-
librbio_handle::Ptr{Cvoid} = C_NULL
3424
librbio_path::String = ""
35-
libspqr_handle::Ptr{Cvoid} = C_NULL
3625
libspqr_path::String = ""
37-
libsuitesparseconfig_handle::Ptr{Cvoid} = C_NULL
3826
libsuitesparseconfig_path::String = ""
39-
libumfpack_handle::Ptr{Cvoid} = C_NULL
4027
libumfpack_path::String = ""
4128

29+
_libamd_dependencies = LazyLibrary[libblastrampoline]
30+
_libbtf_dependencies = LazyLibrary[libblastrampoline]
31+
_libcamd_dependencies = LazyLibrary[libblastrampoline]
32+
_libccolamd_dependencies = LazyLibrary[libblastrampoline]
33+
_libcholmod_dependencies = LazyLibrary[libblastrampoline]
34+
_libcolamd_dependencies = LazyLibrary[libblastrampoline]
35+
_libklu_dependencies = LazyLibrary[libblastrampoline]
36+
_libldl_dependencies = LazyLibrary[]
37+
_librbio_dependencies = LazyLibrary[libblastrampoline]
38+
_libspqr_dependencies = LazyLibrary[libblastrampoline]
39+
_libsuitesparseconfig_dependencies = LazyLibrary[libblastrampoline]
40+
_libumfpack_dependencies = LazyLibrary[libblastrampoline]
41+
4242
if Sys.iswindows()
43-
const libamd = "libamd.dll"
44-
const libbtf = "libbtf.dll"
45-
const libcamd = "libcamd.dll"
46-
const libccolamd = "libccolamd.dll"
47-
const libcholmod = "libcholmod.dll"
48-
const libcolamd = "libcolamd.dll"
49-
const libklu = "libklu.dll"
50-
const libldl = "libldl.dll"
51-
const librbio = "librbio.dll"
52-
const libspqr = "libspqr.dll"
53-
const libsuitesparseconfig = "libsuitesparseconfig.dll"
54-
const libumfpack = "libumfpack.dll"
43+
const _libamd_path = BundledLazyLibraryPath("libamd.dll")
44+
const _libbtf_path = BundledLazyLibraryPath("libbtf.dll")
45+
const _libcamd_path = BundledLazyLibraryPath("libcamd.dll")
46+
const _libccolamd_path = BundledLazyLibraryPath("libccolamd.dll")
47+
const _libcholmod_path = BundledLazyLibraryPath("libcholmod.dll")
48+
const _libcolamd_path = BundledLazyLibraryPath("libcolamd.dll")
49+
const _libklu_path = BundledLazyLibraryPath("libklu.dll")
50+
const _libldl_path = BundledLazyLibraryPath("libldl.dll")
51+
const _librbio_path = BundledLazyLibraryPath("librbio.dll")
52+
const _libspqr_path = BundledLazyLibraryPath("libspqr.dll")
53+
const _libsuitesparseconfig_path = BundledLazyLibraryPath("libsuitesparseconfig.dll")
54+
const _libumfpack_path = BundledLazyLibraryPath("libumfpack.dll")
5555
elseif Sys.isapple()
56-
const libamd = "@rpath/libamd.3.dylib"
57-
const libbtf = "@rpath/libbtf.2.dylib"
58-
const libcamd = "@rpath/libcamd.3.dylib"
59-
const libccolamd = "@rpath/libccolamd.3.dylib"
60-
const libcholmod = "@rpath/libcholmod.5.dylib"
61-
const libcolamd = "@rpath/libcolamd.3.dylib"
62-
const libklu = "@rpath/libklu.2.dylib"
63-
const libldl = "@rpath/libldl.3.dylib"
64-
const librbio = "@rpath/librbio.4.dylib"
65-
const libspqr = "@rpath/libspqr.4.dylib"
66-
const libsuitesparseconfig = "@rpath/libsuitesparseconfig.7.dylib"
67-
const libumfpack = "@rpath/libumfpack.6.dylib"
56+
const _libamd_path = BundledLazyLibraryPath("libamd.3.dylib")
57+
const _libbtf_path = BundledLazyLibraryPath("libbtf.2.dylib")
58+
const _libcamd_path = BundledLazyLibraryPath("libcamd.3.dylib")
59+
const _libccolamd_path = BundledLazyLibraryPath("libccolamd.3.dylib")
60+
const _libcholmod_path = BundledLazyLibraryPath("libcholmod.5.dylib")
61+
const _libcolamd_path = BundledLazyLibraryPath("libcolamd.3.dylib")
62+
const _libklu_path = BundledLazyLibraryPath("libklu.2.dylib")
63+
const _libldl_path = BundledLazyLibraryPath("libldl.3.dylib")
64+
const _librbio_path = BundledLazyLibraryPath("librbio.4.dylib")
65+
const _libspqr_path = BundledLazyLibraryPath("libspqr.4.dylib")
66+
const _libsuitesparseconfig_path = BundledLazyLibraryPath("libsuitesparseconfig.7.dylib")
67+
const _libumfpack_path = BundledLazyLibraryPath("libumfpack.6.dylib")
6868
else
69-
const libamd = "libamd.so.3"
70-
const libbtf = "libbtf.so.2"
71-
const libcamd = "libcamd.so.3"
72-
const libccolamd = "libccolamd.so.3"
73-
const libcholmod = "libcholmod.so.5"
74-
const libcolamd = "libcolamd.so.3"
75-
const libklu = "libklu.so.2"
76-
const libldl = "libldl.so.3"
77-
const librbio = "librbio.so.4"
78-
const libspqr = "libspqr.so.4"
79-
const libsuitesparseconfig = "libsuitesparseconfig.so.7"
80-
const libumfpack = "libumfpack.so.6"
69+
const _libamd_path = BundledLazyLibraryPath("libamd.so.3")
70+
const _libbtf_path = BundledLazyLibraryPath("libbtf.so.2")
71+
const _libcamd_path = BundledLazyLibraryPath("libcamd.so.3")
72+
const _libccolamd_path = BundledLazyLibraryPath("libccolamd.so.3")
73+
const _libcholmod_path = BundledLazyLibraryPath("libcholmod.so.5")
74+
const _libcolamd_path = BundledLazyLibraryPath("libcolamd.so.3")
75+
const _libklu_path = BundledLazyLibraryPath("libklu.so.2")
76+
const _libldl_path = BundledLazyLibraryPath("libldl.so.3")
77+
const _librbio_path = BundledLazyLibraryPath("librbio.so.4")
78+
const _libspqr_path = BundledLazyLibraryPath("libspqr.so.4")
79+
const _libsuitesparseconfig_path = BundledLazyLibraryPath("libsuitesparseconfig.so.7")
80+
const _libumfpack_path = BundledLazyLibraryPath("libumfpack.so.6")
81+
end
82+
83+
const libamd = LazyLibrary(_libamd_path, dependencies=_libamd_dependencies)
84+
const libbtf = LazyLibrary(_libbtf_path, dependencies=_libbtf_dependencies)
85+
const libcamd = LazyLibrary(_libcamd_path, dependencies=_libcamd_dependencies)
86+
const libccolamd = LazyLibrary(_libccolamd_path, dependencies=_libccolamd_dependencies)
87+
const libcholmod = LazyLibrary(_libcholmod_path, dependencies=_libcholmod_dependencies)
88+
const libcolamd = LazyLibrary(_libcolamd_path, dependencies=_libcolamd_dependencies)
89+
const libklu = LazyLibrary(_libklu_path, dependencies=_libklu_dependencies)
90+
const libldl = LazyLibrary(_libldl_path, dependencies=_libldl_dependencies)
91+
const librbio = LazyLibrary(_librbio_path, dependencies=_librbio_dependencies)
92+
const libspqr = LazyLibrary(_libspqr_path, dependencies=_libspqr_dependencies)
93+
const libsuitesparseconfig = LazyLibrary(_libsuitesparseconfig_path, dependencies=_libsuitesparseconfig_dependencies)
94+
const libumfpack = LazyLibrary(_libumfpack_path, dependencies=_libumfpack_dependencies)
95+
96+
97+
function eager_mode()
98+
dlopen(libamd)
99+
dlopen(libbtf)
100+
dlopen(libcamd)
101+
dlopen(libccolamd)
102+
dlopen(libcholmod)
103+
dlopen(libcolamd)
104+
dlopen(libklu)
105+
dlopen(libldl)
106+
dlopen(librbio)
107+
dlopen(libspqr)
108+
dlopen(libsuitesparseconfig)
109+
dlopen(libumfpack)
110+
81111
end
112+
is_available() = true
82113

83114
function __init__()
84115
libblastrampoline_jll.eager_mode()
85116

86117
# BSD-3-Clause
87-
global libamd_handle = dlopen(libamd)
88-
global libamd_path = dlpath(libamd_handle)
89-
global libcamd_handle = dlopen(libcamd)
90-
global libcamd_path = dlpath(libcamd_handle)
91-
global libccolamd_handle = dlopen(libccolamd)
92-
global libccolamd_path = dlpath(libccolamd_handle)
93-
global libcolamd_handle = dlopen(libcolamd)
94-
global libcolamd_path = dlpath(libcolamd_handle)
95-
global libsuitesparseconfig_handle = dlopen(libsuitesparseconfig)
96-
global libsuitesparseconfig_path = dlpath(libsuitesparseconfig_handle)
118+
global libamd_path = string(_libamd_path)
119+
global libcamd_path = string(_libcamd_path)
120+
global libccolamd_path = string(_libccolamd_path)
121+
global libsuitesparseconfig_path = string(_libsuitesparseconfig_path)
97122

98123
# LGPL-2.1+
99-
global libbtf_handle = dlopen(libbtf)
100-
global libbtf_path = dlpath(libbtf_handle)
101-
global libklu_handle = dlopen(libklu)
102-
global libklu_path = dlpath(libklu_handle)
103-
global libldl_handle = dlopen(libldl)
104-
global libldl_path = dlpath(libldl_handle)
124+
global libbtf_path = string(_libbtf_path)
125+
global libklu_path = string(_libklu_path)
126+
global libldl_path = string(_libldl_path)
105127

106128
# GPL-2.0+
107129
if Base.USE_GPL_LIBS
108-
global libcholmod_handle = dlopen(libcholmod)
109-
global libcholmod_path = dlpath(libcholmod_handle)
110-
global librbio_handle = dlopen(librbio)
111-
global librbio_path = dlpath(librbio_handle)
112-
global libspqr_handle = dlopen(libspqr)
113-
global libspqr_path = dlpath(libspqr_handle)
114-
global libumfpack_handle = dlopen(libumfpack)
115-
global libumfpack_path = dlpath(libumfpack_handle)
130+
global libcholmod_path = string(_libcholmod_path)
131+
global librbio_path = string(_librbio_path)
132+
global libspqr_path = string(_libspqr_path)
133+
global libumfpack_path = string(_libumfpack_path)
116134
end
117135
global artifact_dir = dirname(Sys.BINDIR)
118136
end
119137

120-
# JLLWrappers API compatibility shims. Note that not all of these will really make sense.
121-
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because
122-
# there isn't one. It instead returns the overall Julia prefix.
123-
is_available() = true
124-
find_artifact_dir() = artifact_dir
125-
dev_jll() = error("stdlib JLLs cannot be dev'ed")
126-
best_wrapper = nothing
127-
get_libamd_path() = libamd_path
128-
get_libbtf_path() = libbtf_path
129-
get_libcamd_path() = libcamd_path
130-
get_libccolamd_path() = libccolamd_path
131-
get_libcholmod_path() = libcholmod_path
132-
get_libcolamd_path() = libcolamd_path
133-
get_libklu_path() = libklu_path
134-
get_libldl_path() = libldl_path
135-
get_librbio_path() = librbio_path
136-
get_libspqr_path() = libspqr_path
137-
get_libsuitesparseconfig_path() = libsuitesparseconfig_path
138-
get_libumfpack_path() = libumfpack_path
139-
140138
end # module SuiteSparse_jll

0 commit comments

Comments
 (0)