Skip to content

Commit fdb3f2e

Browse files
lazify GMP_jll
1 parent ce92d22 commit fdb3f2e

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

stdlib/GMP_jll/src/GMP_jll.jl

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,53 @@
44
baremodule GMP_jll
55
using Base, Libdl
66

7-
const PATH_list = String[]
8-
const LIBPATH_list = String[]
9-
107
export libgmp, libgmpxx
118

129
# These get calculated in __init__()
1310
const PATH = Ref("")
11+
const PATH_list = String[]
1412
const LIBPATH = Ref("")
13+
const LIBPATH_list = String[]
1514
artifact_dir::String = ""
16-
libgmp_handle::Ptr{Cvoid} = C_NULL
1715
libgmp_path::String = ""
18-
libgmpxx_handle::Ptr{Cvoid} = C_NULL
1916
libgmpxx_path::String = ""
2017

18+
_libgmp_dependencies = LazyLibrary[]
19+
_libgmpxx_dependencies = LazyLibrary[]
20+
2121
if Sys.iswindows()
22-
const libgmp = "libgmp-10.dll"
23-
const libgmpxx = "libgmpxx-4.dll"
22+
const _libgmp_path = BundledLazyLibraryPath("libgmp-10.dll")
23+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx-4.dll")
2424
elseif Sys.isapple()
25-
const libgmp = "@rpath/libgmp.10.dylib"
26-
const libgmpxx = "@rpath/libgmpxx.4.dylib"
25+
const _libgmp_path = BundledLazyLibraryPath("libgmp.10.dylib")
26+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.4.dylib")
2727
else
28-
const libgmp = "libgmp.so.10"
29-
const libgmpxx = "libgmpxx.so.4"
28+
const _libgmp_path = BundledLazyLibraryPath("libgmp.so.10")
29+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.so.4")
3030
end
3131

32+
const libgmp = LazyLibrary(
33+
_libgmp_path,
34+
dependencies=_libgmp_dependencies,
35+
)
36+
37+
const libgmpxx = LazyLibrary(
38+
_libgmpxx_path,
39+
dependencies=_libgmpxx_dependencies,
40+
)
41+
42+
function eager_mode()
43+
dlopen(libgmp)
44+
dlopen(libgmpxx)
45+
end
46+
is_available() = true
47+
3248
function __init__()
33-
global libgmp_handle = dlopen(libgmp)
34-
global libgmp_path = dlpath(libgmp_handle)
35-
global libgmpxx_handle = dlopen(libgmpxx)
36-
global libgmpxx_path = dlpath(libgmpxx_handle)
49+
global libgmp_path = string(_libgmp_path)
50+
global libgmpxx_path = string(_libgmpxx_path)
3751
global artifact_dir = dirname(Sys.BINDIR)
3852
LIBPATH[] = dirname(libgmp_path)
3953
push!(LIBPATH_list, LIBPATH[])
4054
end
4155

42-
# JLLWrappers API compatibility shims. Note that not all of these will really make sense.
43-
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because
44-
# there isn't one. It instead returns the overall Julia prefix.
45-
is_available() = true
46-
find_artifact_dir() = artifact_dir
47-
dev_jll() = error("stdlib JLLs cannot be dev'ed")
48-
best_wrapper = nothing
49-
get_libgmp_path() = libgmp_path
50-
get_libgmpxx_path() = libgmpxx_path
51-
5256
end # module GMP_jll

0 commit comments

Comments
 (0)