Skip to content

Commit 5e7db50

Browse files
lazify GMP_jll
1 parent 91b4fcc commit 5e7db50

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

stdlib/GMP_jll/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "6.3.0+2"
44

55
[deps]
66
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
7+
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
78
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
89

910
[compat]

stdlib/GMP_jll/src/GMP_jll.jl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,51 @@
22

33
## dummy stub for https://github.com/JuliaBinaryWrappers/GMP_jll.jl
44
baremodule GMP_jll
5-
using Base, Libdl
6-
7-
const PATH_list = String[]
8-
const LIBPATH_list = String[]
5+
using Base, Libdl, CompilerSupportLibraries_jll
96

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

2118
if Sys.iswindows()
22-
const libgmp = "libgmp-10.dll"
23-
const libgmpxx = "libgmpxx-4.dll"
19+
const _libgmp_path = BundledLazyLibraryPath("libgmp-10.dll")
20+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx-4.dll")
2421
elseif Sys.isapple()
25-
const libgmp = "@rpath/libgmp.10.dylib"
26-
const libgmpxx = "@rpath/libgmpxx.4.dylib"
22+
const _libgmp_path = BundledLazyLibraryPath("libgmp.10.dylib")
23+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.4.dylib")
2724
else
28-
const libgmp = "libgmp.so.10"
29-
const libgmpxx = "libgmpxx.so.4"
25+
const _libgmp_path = BundledLazyLibraryPath("libgmp.so.10")
26+
const _libgmpxx_path = BundledLazyLibraryPath("libgmpxx.so.4")
27+
end
28+
29+
const libgmp = LazyLibrary(_libgmp_path)
30+
31+
_libgmpxx_dependencies = LazyLibrary[libgmp, libstdcxx, libgcc_s]
32+
const libgmpxx = LazyLibrary(
33+
_libgmpxx_path,
34+
dependencies=_libgmpxx_dependencies,
35+
)
36+
37+
function eager_mode()
38+
CompilerSupportLibraries_jll.eager_mode()
39+
dlopen(libgmp)
40+
dlopen(libgmpxx)
3041
end
42+
is_available() = true
3143

3244
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)
45+
global libgmp_path = string(_libgmp_path)
46+
global libgmpxx_path = string(_libgmpxx_path)
3747
global artifact_dir = dirname(Sys.BINDIR)
3848
LIBPATH[] = dirname(libgmp_path)
3949
push!(LIBPATH_list, LIBPATH[])
4050
end
4151

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-
5252
end # module GMP_jll

stdlib/GMP_jll/test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
using Test, Libdl, GMP_jll
44

55
@testset "GMP_jll" begin
6-
vn = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, libgmp), Ptr{Cchar}))))
6+
vn = VersionNumber(unsafe_string(unsafe_load(cglobal(dlsym(libgmp, :__gmp_version), Ptr{Cchar}))))
77
@test vn == v"6.3.0"
88
end

0 commit comments

Comments
 (0)