Skip to content

Commit 3b59907

Browse files
staticfloatvchuravy
authored andcommitted
More lazy JLL stdlibs
* `OpenBLAS_jll` * `CompilerSupportLibraries_jll` * `dSFMT_jll`
1 parent 01c131d commit 3b59907

File tree

5 files changed

+43
-97
lines changed

5 files changed

+43
-97
lines changed

stdlib/CompilerSupportLibraries_jll/src/CompilerSupportLibraries_jll.jl

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,57 @@ baremodule CompilerSupportLibraries_jll
66
using Base, Libdl, Base.BinaryPlatforms
77
Base.Experimental.@compiler_options compile=min optimize=0 infer=false
88

9-
const PATH_list = String[]
10-
const LIBPATH_list = String[]
11-
12-
export libgfortran, libstdcxx, libgomp
13-
14-
# These get calculated in __init__()
15-
const PATH = Ref("")
16-
const LIBPATH = Ref("")
17-
artifact_dir::String = ""
18-
libgfortran_handle::Ptr{Cvoid} = C_NULL
19-
libgfortran_path::String = ""
20-
libstdcxx_handle::Ptr{Cvoid} = C_NULL
21-
libstdcxx_path::String = ""
22-
libgomp_handle::Ptr{Cvoid} = C_NULL
23-
libgomp_path::String = ""
9+
export libgcc_s, libgomp, libstdcxx, libquadmath, libgfortran, libssp
2410

2511
if Sys.iswindows()
2612
if arch(HostPlatform()) == "x86_64"
27-
const libgcc_s = "libgcc_s_seh-1.dll"
13+
const libgcc_s_name = "bin/libgcc_s_seh-1.dll"
2814
else
29-
const libgcc_s = "libgcc_s_sjlj-1.dll"
15+
const libgcc_s_name = "bin/libgcc_s_sjlj-1.dll"
3016
end
31-
const libgfortran = string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll")
32-
const libstdcxx = "libstdc++-6.dll"
33-
const libgomp = "libgomp-1.dll"
34-
const libssp = "libssp-0.dll"
17+
const libgomp_name = "bin/libgomp-1.dll"
18+
const libstdcxx_name = "bin/libstdc++-6.dll"
19+
const libquadmath_name = "bin/libquadmath-0.dll"
20+
const libgfortran_name = string("bin/libgfortran-", libgfortran_version(HostPlatform()).major, ".dll")
21+
const libssp_name = "bin/libssp-0.dll"
3522
elseif Sys.isapple()
3623
if arch(HostPlatform()) == "aarch64" || libgfortran_version(HostPlatform()) == v"5"
37-
const libgcc_s = "@rpath/libgcc_s.1.1.dylib"
24+
const libgcc_s_name = "lib/libgcc_s.1.1.dylib"
3825
else
39-
const libgcc_s = "@rpath/libgcc_s.1.dylib"
26+
const libgcc_s_name = "lib/libgcc_s.1.dylib"
4027
end
41-
const libgfortran = string("@rpath/", "libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib")
42-
const libstdcxx = "@rpath/libstdc++.6.dylib"
43-
const libgomp = "@rpath/libgomp.1.dylib"
44-
const libssp = "@rpath/libssp.0.dylib"
28+
const libgomp_name = "lib/libgomp.1.dylib"
29+
const libstdcxx_name = "lib/libstdc++.6.dylib"
30+
const libquadmath_name = "lib/libquadmath.0.dylib"
31+
const libgfortran_name = string("lib/", "libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib")
32+
const libssp_name = "lib/libssp.0.dylib"
4533
else
46-
const libgcc_s = "libgcc_s.so.1"
47-
const libgfortran = string("libgfortran.so.", libgfortran_version(HostPlatform()).major)
48-
const libstdcxx = "libstdc++.so.6"
49-
const libgomp = "libgomp.so.1"
34+
const libgcc_s_name = "lib/libgcc_s.so.1"
35+
const libgomp_name = "lib/libgomp.so.1"
36+
const libstdcxx_name = "lib/libstdc++.so.6"
37+
const libquadmath_name = "lib/libquadmath.so.0"
38+
const libgfortran_name = string("lib/libgfortran.so.", libgfortran_version(HostPlatform()).major)
5039
if libc(HostPlatform()) != "musl"
51-
const libssp = "libssp.so.0"
40+
const libssp_name = "lib/libssp.so.0"
5241
end
5342
end
5443

55-
function __init__()
56-
global libgcc_s_handle = dlopen(libgcc_s)
57-
global libgcc_s_path = dlpath(libgcc_s_handle)
58-
global libgfortran_handle = dlopen(libgfortran)
59-
global libgfortran_path = dlpath(libgfortran_handle)
60-
global libstdcxx_handle = dlopen(libstdcxx)
61-
global libstdcxx_path = dlpath(libstdcxx_handle)
62-
global libgomp_handle = dlopen(libgomp)
63-
global libgomp_path = dlpath(libgomp_handle)
64-
@static if libc(HostPlatform()) != "musl"
65-
dlopen(libssp; throw_error = false)
66-
end
67-
global artifact_dir = dirname(Sys.BINDIR)
68-
LIBPATH[] = dirname(libgcc_s_path)
69-
push!(LIBPATH_list, LIBPATH[])
44+
const libgcc_s_path = BundledLazyLibraryPath(libgcc_s_name)
45+
const libgomp_path = BundledLazyLibraryPath(libgomp_name)
46+
const libstdcxx_path = BundledLazyLibraryPath(libstdcxx_name)
47+
const libquadmath_path = BundledLazyLibraryPath(libquadmath_name)
48+
const libgfortran_path = BundledLazyLibraryPath(libgfortran_name)
49+
if libc(HostPlatform()) != "musl"
50+
const libssp_path = BundledLazyLibraryPath(libssp_name)
7051
end
7152

72-
# JLLWrappers API compatibility shims. Note that not all of these will really make sense.
73-
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because
74-
# there isn't one. It instead returns the overall Julia prefix.
75-
is_available() = true
76-
find_artifact_dir() = artifact_dir
77-
dev_jll() = error("stdlib JLLs cannot be dev'ed")
78-
best_wrapper = nothing
79-
get_libgfortran_path() = libgfortran_path
80-
get_libstdcxx_path() = libstdcxx_path
81-
get_libgomp_path() = libgomp_path
53+
const libgcc_s = LazyLibrary(libgcc_s_path)
54+
const libgomp = LazyLibrary(libgomp_path)
55+
const libstdcxx = LazyLibrary(libstdcxx_path; dependencies=[libgcc_s])
56+
const libquadmath = LazyLibrary(libquadmath_path)
57+
const libgfortran = LazyLibrary(libgfortran_path; dependencies=[libquadmath, libgcc_s])
58+
if libc(HostPlatform()) != "musl"
59+
const libssp = LazyLibrary(libssp_path)
60+
end
8261

8362
end # module CompilerSupportLibraries_jll

stdlib/MbedTLS_jll/src/MbedTLS_jll.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const libmbedx509_path = BundledLazyLibraryPath(libmbedx509_name)
2626

2727
const libmbedcrypto = LazyLibrary(libmbedcrypto_path)
2828
const libmbedx509 = LazyLibrary(libmbedx509_path; dependencies=[libmbedcrypto])
29-
libmbedtls_stack = Any[]
30-
const libmbedtls = LazyLibrary(libmbedtls_path; dependencies=[libmbedcrypto, libmbedx509], on_load_callback = () -> push!(libmbedtls_stack, stacktrace()))
29+
const libmbedtls = LazyLibrary(libmbedtls_path; dependencies=[libmbedcrypto, libmbedx509])
3130

3231
end # module MbedTLS_jll

stdlib/OpenBLAS_jll/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
33
version = "0.3.23+0"
44

55
[deps]
6-
# See note in `src/OpenBLAS_jll.jl` about this dependency.
76
CompilerSupportLibraries_jll = "e66e0078-7015-5450-92f7-15fbd957f2ae"
87
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
98
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

stdlib/OpenBLAS_jll/src/OpenBLAS_jll.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## dummy stub for https://github.com/JuliaBinaryWrappers/OpenBLAS_jll.jl
44
baremodule OpenBLAS_jll
5-
using Base, Libdl, Base.BinaryPlatforms
5+
using Base, Libdl, Base.BinaryPlatforms, CompilerSupportLibraries_jll
66
export libopenblas
77

88
if Base.USE_BLAS64
@@ -13,18 +13,12 @@ end
1313

1414
if Sys.iswindows()
1515
const libopenblas_name = "bin/libopenblas$(libsuffix).dll"
16-
const libgfortran_name = string("libgfortran-", libgfortran_version(HostPlatform()).major, ".dll")
1716
elseif Sys.isapple()
1817
const libopenblas_name = "lib/libopenblas$(libsuffix).dylib"
19-
const libgfortran_name = string("lib/libgfortran.", libgfortran_version(HostPlatform()).major, ".dylib")
2018
else
2119
const libopenblas_name = "lib/libopenblas$(libsuffix).so"
22-
const libgfortran_name = string("lib/libgfortran.so.", libgfortran_version(HostPlatform()).major)
2320
end
2421

25-
const libgfortran_path = BundledLazyLibraryPath(libgfortran_name)
26-
const libgfortran = LazyLibrary(libgfortran_path)
27-
2822
const libopenblas_path = BundledLazyLibraryPath(libopenblas_name)
2923
const libopenblas = LazyLibrary(libopenblas_path; dependencies=[libgfortran])
3024

stdlib/dSFMT_jll/src/dSFMT_jll.jl

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,16 @@ baremodule dSFMT_jll
66
using Base, Libdl
77
Base.Experimental.@compiler_options compile=min optimize=0 infer=false
88

9-
const PATH_list = String[]
10-
const LIBPATH_list = String[]
11-
129
export libdSFMT
1310

14-
# These get calculated in __init__()
15-
const PATH = Ref("")
16-
const LIBPATH = Ref("")
17-
artifact_dir::String = ""
18-
libdSFMT_handle::Ptr{Cvoid} = C_NULL
19-
libdSFMT_path::String = ""
20-
2111
if Sys.iswindows()
22-
const libdSFMT = "libdSFMT.dll"
12+
const libdSFMT_name = "bin/libdSFMT.dll"
2313
elseif Sys.isapple()
24-
const libdSFMT = "@rpath/libdSFMT.dylib"
14+
const libdSFMT_name = "lib/libdSFMT.dylib"
2515
else
26-
const libdSFMT = "libdSFMT.so"
16+
const libdSFMT_name = "lib/libdSFMT.so"
2717
end
28-
29-
function __init__()
30-
global libdSFMT_handle = dlopen(libdSFMT)
31-
global libdSFMT_path = dlpath(libdSFMT_handle)
32-
global artifact_dir = dirname(Sys.BINDIR)
33-
LIBPATH[] = dirname(libdSFMT_path)
34-
push!(LIBPATH_list, LIBPATH[])
35-
end
36-
37-
# JLLWrappers API compatibility shims. Note that not all of these will really make sense.
38-
# For instance, `find_artifact_dir()` won't actually be the artifact directory, because
39-
# there isn't one. It instead returns the overall Julia prefix.
40-
is_available() = true
41-
find_artifact_dir() = artifact_dir
42-
dev_jll() = error("stdlib JLLs cannot be dev'ed")
43-
best_wrapper = nothing
44-
get_libdSFMT_path() = libdSFMT_path
18+
const libdSFMT_path = BundledLazyLibraryPath(libdSFMT_name)
19+
const libdSFMT = LazyLibrary(libdSFMT_path)
4520

4621
end # module dSFMT_jll

0 commit comments

Comments
 (0)